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 |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-25 : 04:19:49
|
| hi i have a question about intersectassuming i have 2 tabletableAcustid | custname1 | kim2 | mary3 | johntableBtrxno | custid5 | 16 | 27 | 4how to get the following data by using intersect?5 | 1 | kim6 | 2 | maryi have around 5 table to intersect with...jz gimi a guide on using intersect will be helpful >"< thx |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-05-25 : 04:22:59
|
| select a.custid, b.trxno, a.custnamefrom TableA ajoin TableB bon a.custid = b.custid==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-05-25 : 04:24:10
|
| select b.trxno,a.custid, a.custname from tablea a inner join tableb b on b.custid = a.custid |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-25 : 04:25:23
|
| thx thx...i think i won able to use intersect..xD |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-05-25 : 04:48:05
|
| while using the intersect,union,except the columns should be equal datatype in the both tables then only we can use intersect,union,exceptfor this u can use this oneselect custid from @t intersect select custid from @b |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-05-25 : 04:54:24
|
| Why do you want use intersect?It will only give the custid's then you would have to join to the tables to get the resultset anyway.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-25 : 05:23:37
|
| coz when i read the instruction, there written something like returning data which included in both table..so i thought must use intersect x.x |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-05-25 : 05:36:11
|
| Nope - that's a join as in my first post.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|