is it possible to get data from 3 tables with one SELECT statement?
Let's say I have three tables (tableA, tableB, tableC). Each table has a primary key, and tableB has a foreign key that references tableA, and tableC has a foreign key that references tableB. Could we get one specific record using a select statement that would give us the related data from all three tables?
Re: is it possible to get data from 3 tables with one SELECT statement?
Something like this :
Code:
SELECT TableA.Field1, TableA.Field2, TableB.FieldN, TableC.FieldM
FROM TableA
INNER JOIN TableB ON TableA.PKey = TableB.FKeyA
INNER JOIN TableC ON TableB.PKey = TableC.FKeyB
WHERE TableA.Field1 = 'XXXX'
Just change the fields' names & add the real ones
JG
Re: is it possible to get data from 3 tables with one SELECT statement?
Quote:
Originally Posted by
jggtz
Something like this :
Code:
SELECT TableA.Field1, TableA.Field2, TableB.FieldN, TableC.FieldM
FROM TableA
INNER JOIN TableB ON TableA.PKey = TableB.FKeyA
INNER JOIN TableC ON TableB.PKey = TableC.FKeyB
WHERE TableA.Field1 = 'XXXX'
Just change the fields' names & add the real ones
JG
Cool, thanks. I'll try it out.