Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join three tables

Status
Not open for further replies.

Xaplytz

Programmer
Jun 26, 2000
79
US
I have three tables
A transaction table, Customer Table and Inventory Table
And I have to make a Query to show the transaction with the
Customer Name and the Item description.


Table-A Transactions
Table- B Customers
Table- C Items

Between them are two common fields TA.x with TB.x and TA.y with TC.y.,when I try to make a Query with a SELECT,
I just can pull the data from two tables when I try to use
The third table I get Nothing .

Did somebody has done this before with some [Join] or special [Where] I will appreciate any help
Thank.


[sig][/sig]
 
Javier, if there is not at least one matching record in all three tables (an "inner" join), then you will correctly get zero records.

If you do have at least one match across all three tables, then post your SELECT statement and let's have a look. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Can you post a query you made? It is much more easy to discuss query than try to understand what you want from words.
I will try to write query you want, but I'm not sure it is what you want:

SELECT ta.*, tb.*, tc.*
from Transactions ta
inner join customer tb
on ta.x = tb.x
inner join Items tc
on ta.y = tc.y

If transaction table contain coorect link records between customers and items, above query should not return empty result.
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br><a href= Serve</a><br>The professional level of programmer could be determined by level of stupidity of his/her bugs[/sig]
 
I had a similar problem myself recently, i had problems using inner join so this is the SQL Scripting i used.

SELECT op.ID, op.custRef, op.orderSo,......etc.....

FROM custuser AS cu, customers AS c, pipe AS p

WHERE cu.userid =
usergivenid AND
cu.custid = c.id AND
c.spid = p.spid


Hope it helps,

Deltaflyer

[sig][/sig]
 
Try

SELECT A.*,B.*,C.*
FROM A,B,C
WHERE A.X=B.X,
AND B.Y=C.Y;

Is a valid SQL and should get the required results [sig]<p>Cal<br><a href=mailto: > </a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top