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 |
|
duf
Starting Member
39 Posts |
Posted - 2012-01-03 : 09:25:25
|
| When I join two tables all records are linked in these tables. Is it possible to connect only one record from the table number one with one record of table number two? Of course, if and only if the conditions are met to join tables. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-01-03 : 09:32:38
|
can you give any examples? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-03 : 10:51:30
|
quote: Originally posted by duf When I join two tables all records are linked in these tables. Is it possible to connect only one record from the table number one with one record of table number two? Of course, if and only if the conditions are met to join tables.
It depends on how you're joining tablesif joining without any condition, it causes all records to be linked to form a cartesian product. If you specify condition, it will do the join only based on condition.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
duf
Starting Member
39 Posts |
Posted - 2012-01-03 : 13:50:41
|
| For example:first table IDCNCNID...CN001....6001002....5201003....4810second table IDDATAID...DATA...CNID1....Aaaa...0012....Bbbb...0023....Cccc...003Joining:SELECT CN, DATA FROM IDCN, IDDATA WHERE IDCN.CNID=IDDATA.CNIDRESULT INQUIRY:CN....DATA6001..Aaaa5201..Bbbb4810..CcccAll data from two tables are combined. Can I get just the result of combining a single record from two tables? I would like to obtain only just like this result of combining:CN....DATA5201..BbbbCan I identify which records are to be connected? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-03 : 13:59:25
|
| [code]SELECT CN, DATA FROM IDCN, IDDATA WHERE IDCN.CNID=IDDATA.CNIDAND IDCN.CN=5201[/code]or a similar clause that limits the data to the row(s) that you are interested in. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-03 : 14:16:16
|
quote: BRILLIANT!!!!Brett
Brett! Happy New Year to you too!! |
 |
|
|
|
|
|
|
|