Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2005, 01:05 PM
mmeyer mmeyer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Italy
Posts: 27 mmeyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 5 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old December 8th, 2005, 12:08 PM
xpi0t0s xpi0t0s is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 19 xpi0t0s User rank is Private First Class (20 - 50 Reputation Level)xpi0t0s User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 13 m 51 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old December 8th, 2005, 03:03 PM
JasonConroy JasonConroy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 1 JasonConroy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 22 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old December 9th, 2005, 11:37 AM
mmeyer mmeyer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Italy
Posts: 27 mmeyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 5 sec
Reputation Power: 0
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???

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Querying multiple tables.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT