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

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -