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 |
abuhassan
105 Posts |
Posted - 2007-03-15 : 09:32:22
|
Hi I have two tables and one linking table they look something like this<<<<<<<Application Table>>>>>>AppID AppName1 MS Word2 Excel3 SoftGrid<<<<<<System Table>>>>>>>>SysID SysName1 System 12 System 23 Server 1<<<<<<Link Table>>>>>>>>>SysID AppID1 11 3How can i retirve the data so that it picks up and displays all the applications that are not on the the server as well as those that arefor example the output im trying to get is as follows from the data above.......SysName AppName Y/NSystem 1 MS Word YSystem 1 Excel NSystem 1 SoftGrid YSystem 2 MS Word NSystem 2 Excel NSystem 2 SoftGrid NServer 1 MS Word NServer 1 Excel NServer 1 SoftGrid Ni want to able to get a dynamically generated Y/N colunmIm ok with doing innerjoin queries but the problem is how do i get the rest of the results that have no links to show that there it does not exist.Thanks |
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2007-03-15 : 09:36:32
|
select s.sysname, a.appname,case when exists (select 1 from linktable where sysid=s.sysid and appid=a.appid) then 'Y' else 'N' end as [Y/N]from system s cross join application a |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-15 : 09:39:36
|
[code]select s.sysname, a.appname, case when l.sysid is null then 'N' else 'Y' end as [Y/N]from system as scross join application as aleft join linktable as l on l.sysid = s.sysid and l.appid = a.appid[/code]Peter LarssonHelsingborg, Sweden |
|
|
abuhassan
105 Posts |
Posted - 2007-03-15 : 09:46:30
|
ThanksNever used or come accross a cross join before where can i learn more about them? does any one have good links to it? |
|
|
|
|
|