| Author |
Topic |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 04:33:57
|
| HI could any one answer this question i got a solution but its not resonable one.You have 2 tables: tableA and table B. The ID field in tableA maps to the FKtableAField in tableB.Write a SQL Query that would return all the records in tableA and the value the primary key and field1 from tableB where it exists.tableA definitionID int primary key,field1 varchar(10),field2 varchar(10)tableB definitionPK int primary key,field1 varchar(10),field2 varchar(10),FKtableA intthanxSatya |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 04:46:10
|
| What's the solution you already have, and what's wrong with it?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 04:48:43
|
i am using the liftouter join for the tableb could u plz tell ur idea for writing this query plz.quote: Originally posted by DBA in the making What's the solution you already have, and what's wrong with it?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee.
Satya |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 04:54:15
|
| Well, there could be more than one record in Table B for each record in table A, so a LEFT JOIN (which is what I was thinking) would possibly return multiple copies of the records in table A. Is that what you're after?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 04:58:01
|
| select * from tableAleft outer join tableA.id=tableB.field1this is the script i gotbut its not workingSatya |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 05:08:26
|
could you tell me how to write a script for getting without multiple records form tableBquote: Originally posted by DBA in the making Well, there could be more than one record in Table B for each record in table A, so a LEFT JOIN (which is what I was thinking) would possibly return multiple copies of the records in table A. Is that what you're after?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee.
Satya |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 05:14:40
|
| If each record in table A has multiple records in table B, and you want to see records from table A and columns from table B, but you only want to see each record from table A once, then how do you determine which of the multiple records in table B should be joined to table A?------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 05:19:14
|
| field1 in tableB should join to tableAcould u tell the script by joining this..plsSatya |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 05:35:02
|
quote: Originally posted by satya068 field1 in tableB should join to tableA
Yes, I've got that. The question was "which RECORD" from table B should be joined to those of table A.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-04-12 : 05:41:09
|
| ALL THE REOCRDS FROM feild1 in tableBSatya |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-04-12 : 05:47:39
|
select * from tableAleft outer join tableA.field1=tableB.field1 PBUH |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-12 : 05:55:55
|
quote: Originally posted by satya068 ALL THE REOCRDS FROM feild1 in tableBSatya
You're going to have to supply some sample data, and a sample output. What you're asking for doesn't seem to make sense.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
|