Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
darms21
Yak Posting Veteran
54 Posts |
Posted - 2012-06-14 : 16:07:46
|
I have the following queryselect *from Awhere name like '1' or name like '2' or name like '3' The table has name like 1 and name like 2 but I want the results set to show as follows: 1 yes2 yes3 no Any idea how I can get a result set that will include all items from the where clause in the result set and then indicate if it was found or not in the defined table?Thanks! |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-06-14 : 16:16:42
|
SELECT N.N, CASE WHEN A.Name IS NULL THEN 'no' ELSE 'yes' ENDFROM (SELECT '1' N UNION ALL SELECT '2' UNION ALL SELECT '3') NLEFT JOIN A ON N.N=A.Name |
|
|
|
|
|