Jump to content

Sql Query Help


Recommended Posts

Posted

A B C are the three table
A is the parent table
B is linked by the parent table,dhani primary key and indhulo seq number ni kalipi o primary key chesaru
C table vachi related to B....And c table lo multiple rows related to B coz A lo primary key ,B lo sequence numberand C lo sequence number
ni kalipi primary key chesaru

So i am tryin to pull data from 3 tables A and B antte parledhu...kani C lo multiple rows are
related to single row in B ...ela chestharu mama........evaraina cheppandamma... CITI#H@ CITI#H@

  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

  • mtkr

    20

  • deals2buy

    17

  • kotha thread

    16

  • athadu

    7

Top Posters In This Topic

Posted

ardamkaledu bhayya.........inka konchem clear ga cheppagalava...tables columns list chesi and evi primary, evi foreign keys ani

Posted

Yes, Inkoncham clear ga cheppu...asal neeku output emm kavalo and table related c is related to table b antunnav...emm relation undhi...avi fact and diemension tables aa?

Posted

[quote name='CheGuevara' timestamp='1352920385' post='1302796009']
ardamkaledu bhayya.........inka konchem clear ga cheppagalava...tables columns list chesi and evi primary, evi foreign keys ani
[/quote]
@gr33d

Posted

[quote name='CheGuevara' timestamp='1352920385' post='1302796009']
ardamkaledu bhayya.........inka konchem clear ga cheppagalava...tables columns list chesi and evi primary, evi foreign keys ani
[/quote]
Antha clear ga cheppanu kada...:P...A is linked to B and B is linked to C..
need to pull data from three tables....problem is C table consists of multiple rows related to single row in B......
So A & B okka query and C oka query rayala...lekah ronddu kalipi okke dhantlo rayocha.....table ippudu copy cheyali.....but try this...mean while chustha

Posted

inner join chesi choodu with the common rows in all the three tables

Posted

[quote name='SREEE' timestamp='1352920607' post='1302796042']
Antha clear ga cheppanu kada... :P...A is linked to B and B is linked to C..
need to pull data from three tables....problem is C table consists of multiple rows related to single row in B......
So A & B okka query and C oka query rayala...lekah ronddu kalipi okke dhantlo rayocha.....table ippudu copy cheyali.....but try this...mean while chustha
[/quote]


Select A.col, B.Col, C.Col
FROM A INNER JOIN B ON A.id = B.id
INNER JOIN C ON B.id = C.id


Add filters too if you have any
sSa_j@il

Posted

[quote name='HyderabadPoradu' timestamp='1352920521' post='1302796026']
Yes, Inkoncham clear ga cheppu...asal neeku output emm kavalo and table related c is related to table b antunnav...emm relation undhi...avi fact and diemension tables aa?
[/quote]
A is Employee Table anuko
B anedhi EmpAddressDetails table anuko
C anedhi PhNumbersTable anuko....(one can have multiple ph numbers)

So A lo nunchi empid vasthundhi....and adhi pattukuntte B lo addressDetails vasthay...
inthavaraku okey.....Kani B lo unna primary Key(Combination of A`s PrimaryKey+B`s Unique Key) is the foreign key
in PhNumbers table.

As i told you earlier....c mapped to B as many to one relation...now naku oksari okka emp details..okke query lo ravali...How sCo_^Y sCo_^Y

Posted

[quote name='SREEE' timestamp='1352921058' post='1302796109']
A is Employee Table anuko
B anedhi EmpAddressDetails table anuko
C anedhi PhNumbersTable anuko....(one can have multiple ph numbers)

So A lo nunchi empid vasthundhi....and adhi pattukuntte B lo addressDetails vasthay...
inthavaraku okey.....Kani B lo unna primary Key(Combination of A`s PrimaryKey+B`s Unique Key) is the foreign key
in PhNumbers table.

As i told you earlier....c mapped to B as many to one relation...now naku oksari okka emp details..okke query lo ravali...How sCo_^Y sCo_^Y
[/quote]


paina nenu cheppindi try chesava? sCo_^Y

Posted

[quote name='9pardhu' timestamp='1352920727' post='1302796056']
inner join chesi choodu with the common rows in all the three tables
[/quote]
[quote name='deals2buy' timestamp='1352920749' post='1302796062']
Select A.col, B.Col, C.Col
FROM A INNER JOIN B ON A.id = B.id
INNER JOIN C ON B.id = C.id


Add filters too if you have any
sSa_j@il
[/quote]


O/P ela vasthundhi mama...
like ila na

ID Name Address Phnumber
1 xxxxx xxxxxxx 64563453
1 xxxxx xxxxxxx 45748545


2 rows vasthaya..if 2numbers untte..oke emp ki....?

Posted

[quote name='SREEE' timestamp='1352921282' post='1302796138']
O/P ela vasthundhi mama...
like ila na

ID Name Address Phnumber
1 xxxxx xxxxxxx 64563453
1 xxxxx xxxxxxx 45748545


2 rows vasthaya..if 2numbers untte..oke emp ki....?
[/quote]
Yes, 2 rows vasthayi since they have phonenumbers and those stuff diff

btw Name, Address raavatam leda?

Posted

If you have emplid and a unique sequence number in Phone numbers, This should be the query. Otherwise Give your complete structure of the tables.

SELECT A.COLUMNS,
B.COLUMNS,
C.COLUMNS
FROM EMPLOYEE_TABLE A
LEFT OUTER JOIN
ADDRESS_TABLE B
ON A.EMPLID = B.EMPLID
LEFT OUTER JOIN
PHONE_TABLE C
ON A.EMPLID = C.EMPLID
AND B.UNIQ_SEQ = C.UNIQ_SEQ
;

Posted

[quote name='GoliMaar' timestamp='1352923023' post='1302796367']
If you have emplid and a unique sequence number in Phone numbers, This should be the query. Otherwise Give your complete structure of the tables.

SELECT A.COLUMNS,
B.COLUMNS,
C.COLUMNS
FROM EMPLOYEE_TABLE A
LEFT OUTER JOIN
ADDRESS_TABLE B
ON A.EMPLID = B.EMPLID
LEFT OUTER JOIN
PHONE_TABLE C
ON A.EMPLID = C.EMPLID
AND B.UNIQ_SEQ = C.UNIQ_SEQ
;
[/quote]


OUTER JOIN aithe duplicates vache chances unnayi kada bhayya.

Posted

[quote name='GoliMaar' timestamp='1352923023' post='1302796367']
If you have emplid and a unique sequence number in Phone numbers, This should be the query. Otherwise Give your complete structure of the tables.

SELECT A.COLUMNS,
B.COLUMNS,
C.COLUMNS
FROM EMPLOYEE_[color=#ff0000]TABLE A
LEFT OUTER JOIN[/color]
ADDRESS_TABLE B
ON A.EMPLID = B.EMPLID
[color=#ff0000] LEFT OUTER JOIN
PHONE_TABLE C[/color]
ON A.EMPLID = C.EMPLID
AND B.UNIQ_SEQ = C.UNIQ_SEQ
;
[/quote]
deeni O/p ela untundhi mama....

×
×
  • Create New...