sql - Not taking into account condition -


Suppose i have a parameter @ user id, this can be 0 (no user specified) or own id The structure of the query is as follows:

  If @UserID & gt; Select 0 ... where UserID = @ UserID ... else if select @userid = 0 ... ou ...   

What do I need to do the following structure Select ... where the user id & gt; 0 then userID = @ USIDID and ignore this condition ...

thanks

Set as parameter value instead of 0 (zero)

  Announce @id int set @id = null * From users (id = @ Id) or (@IID is empty)    

Comments

Popular posts from this blog

c# - Roxy file manager in MVC doesn't accept session path -

php - proc_open Too many open files in long running Symfony Console app -

c# - Show a huge number of data in DevExpress GridView -