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 |
vidhyashri
Starting Member
4 Posts |
Posted - 2012-11-15 : 01:02:28
|
I have 2 tables with fieldsphrase table with fields phraseid and phrasename.sample table with sampleid,samplename,phraseid.phraseid phrasename1 xxx2 yyysampleid samplename phraseid1 s1 12 s2 1I need the o/p phraseid phrasename status1 xxx true2 yyy falseSampleid as 1 i am giving as input in select query, according to that phraseid i need to display the status as true.can you send the query for the above scenario. |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2012-11-15 : 01:14:22
|
try this oneselect distinct p.phraseid,p.phrasename,case when p.phraseid in(select phraseid from samples) then 'True'else 'False' end as status from phrase pleft join samples son s.phraseid=p.phraseid |
|
|
vidhyashri
Starting Member
4 Posts |
Posted - 2012-11-15 : 01:20:24
|
i got it . |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-15 : 05:40:01
|
quote: Originally posted by ahmeds08 try this oneselect distinct p.phraseid,p.phrasename,case when p.phraseid in(select phraseid from samples where sampleid = @sampleid) then 'True'else 'False' end as status from phrase pleft join samples son s.phraseid=p.phraseid
not quite what OP looks forthe above small tweak is needed to get required output------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|