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 |
dichanz
Starting Member
2 Posts |
Posted - 2008-01-23 : 04:33:27
|
Hi, I am having 1 tables.....table1 - id,Lidtable2 - actid, Lidtable2's Lid is foreign key relation with table1 - Lidtable1 can have id as primary key & Lid can have multiple values...my query is;;;select * from table 2 with additional column 'depend' as 1 if lid is present in table1 else 0 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-23 : 04:39:00
|
[code]SELECT t2.id,t2.Lid,CASEWHEN t1.Lid IS NOT NULL THEN 1ELSE 0END AS 'Depend'FROM table2 t2LEFT OUTER JOIN table1 t1ON t1.Lid=t2.Lid[/code] |
 |
|
|
|
|