|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Querying multiple tables.
Easy question but too hard for me.
I have some tables with differents columns. tbl1.id tbl1.type tbl1.product tbl2.id tbl2.cod_name tbl3.type_name tbl3.cod_name How do i do a query which gets the result: tbl1.product, tbl1.type_name which is on table 3???? Tks for your help. |
|
#2
|
|||
|
|||
|
how about
SELECT PRODUCT, TYPE FROM TBL1, TBL3 WHERE TYPE=TYPE_NAME; If not, try giving a bit of sample data for tbl1 and tbl3 and what sort of output you want. |
|
#3
|
|||
|
|||
|
I would suggest:
select tbl1.product, tbl3.type_name from tbl1, tbl2, tbl3 where tbl1.id = tbl2.id and tbl2.cod_name = tbl2.cod_name |
|
#4
|
|||
|
|||
|
More complicated
I was not so clear in my question. I mean, I know (I hope) how to do a join like that, the problem is at some point the join does not work anymore. Bellow is my query with problem:
select to_char(cms.invoice.invc_sid), lpad(cms.invoice.store_no, 3, '0')|| cms.invoice.station, cms.invoice.invc_no, cms.inventory.upc, cms.invc_item.item_pos, to_char(cms.invoice.created_date, 'DD.MM.YYYY'), to_char(cms.invoice.modified_date, 'DD.MM.YYYY'), to_char(cms.invoice.post_date, 'DD.MM.YYYY'), cms.invoice.disc_perc, cms.invoice.disc_amt, cms.invc_item.qty, cms.invc_item.orig_price, cms.invc_item.price, cms.pos_tender.tender_name, cms.invc_fee.fee_type from cms.invoice, cms.inventory, cms.invc_item, cms.pos_tender, cms.invc_tender, cms.invc_fee where cms.invoice.post_date > sysdate - 1 and cms.invoice.invc_sid = cms.invc_fee.invc_sid and cms.invc_item.invc_sid = cms.invoice.invc_sid and cms.invc_item.item_sid = cms.inventory.item_sid and cms.invc_tender.invc_sid = cms.invoice.invc_sid and cms.pos_tender.tender_type = cms.invc_tender.tender_type and cms.invoice.sbs_no = cms.pos_tender.sbs_no and cms.invc_fee.invc_sid = cms.invoice.invc_sid order by invoice.sbs_no, invoice.store_no, invoice.invc_no If i take out the line "cms.invc_fee.fee_type" and "cms.invc_fee.invc_sid = cms.invoice.invc_sid" everything works well. I don't receive any error message the only problem is i get no results. I am sure the field cms.invc_fee.invc_sid and cms.invoice.invc_sid contains data. If I do an isolated query it works. What am I mistaking??? |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Querying multiple tables. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|