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 |
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2008-04-08 : 11:41:27
|
| SELECT * FROM A INNER JOIN B ON A.AId = (SELECT B.BId FROM B WHERE (B.AId = 4)) I have two tables Table A has several columns and B has just two columnsB.AId and B.BId.I will pass B.AId as a parameter and that will return more than one B.BId values. Then I need to create a join where A.AId matches B.BId.I tried the above SQL but it says subquery can't return more than one value. In my case it must return more than on value.How can I construct the SQL query.Please Help.Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-08 : 11:44:08
|
| SELECT * FROM A INNER JOIN B ON A.AId =B.BIdAND B.AId = 4 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-08 : 11:45:47
|
[code]SELECT *FROM AINNER JOIN B ON B.BId = A.AIdWHERE B.AId = 4[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-09 : 04:21:12
|
quote: Originally posted by visakh16 SELECT * FROM A INNER JOIN B ON A.AId =B.BIdAND B.AId = 4
It is better to have filtering on WHERE clause otherwise it would make differnece in left and right joinsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|