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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-21 : 12:01:07
|
| I want to select from three tablest16pendall at16pendmvt bnatdocfile nI want to grab the cossn's that are in both tables but only want one listing of cossn's to appear on the screen.I've tried this but getting incorrect syntax near whereselect n.area, n.reg, n.regionname, n.regionacronym as region, n.dist, a.cossn, a.fo, a.flg_cdt, b.cossn, b.mvt_cdtfrom where exist (select cossn from t16pendall a join t16pendmvt b on a.cossn = b.cossn join natdocfile n on n.doc=a.fo) |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-10-21 : 12:05:44
|
| select n.area, n.reg, n.regionname, n.regionacronym as region, n.dist, a.cossn, a.fo, a.flg_cdt, b.cossn, b.mvt_cdtfrom <FROM WHERE?!?!>where exist(select cossn from t16pendall ajoin t16pendmvt b on a.cossn = b.cossnjoin natdocfile n on n.doc=a.fo) |
 |
|
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2010-10-21 : 12:28:52
|
| http://www.w3schools.com/sql/sql_join.asp |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-21 : 13:25:25
|
| Lamprey that's my problem I don't know which table to put down. I have info coming from all three tables. |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-10-21 : 13:30:13
|
| Never mind I got rid of the subquery and this works:select b. cossn, n.area, n.reg, n.regionname, n.regionacronym as region, n.dist, a.cossn, a.fo, a.flg_cdt, b.cossn, b.mvt_cdtfrom t16pendmvt bjoin t16pendall a on a.cossn = b.cossnjoin natdocfile n on n.doc=a.fo |
 |
|
|
|
|
|
|
|