Wednesday, 15 May 2013

sql server - sql select query IN Clause returns nothing -


Whether it is possible to get a value from the parameters passed in these sections, where 1 value does not give anything.

Example:

  Choose ID, & lt; Table & gt; Where id (1,2, 36) and (locale_id = 'n')  

If there is no value in the table in ID2, then it is possible to return to zero in place of a value All is Currently it returns only 2 values ​​

Try it out:

  Choose from table 1 T1 with whistle (* select * values ​​from (1), (2), (36)) V (V)) CTE and T.ID = CTAV (T1Locale_ID = ' N ')  

You will get at least a record per ID

Generates CT3 records, with each value of v Like syntax with CTA on the following version Select from (<1), (2), (36)) v (v) left join table 1 t1 on t1.id = vv And (t1 .locale_id = 'EN')

Read the well on the left side:


No comments:

Post a Comment