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

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

c++ - Redefined variable in the other module -

c# - The item with identity 'Id' already exists in the metadata collection. Parameter name: item -