Complex Query Building Help

M

Murtaza

Hi,
I am having a problem in building this query, here's the situation:

I have 3 tables 'a' 'b' and 'c'
Now in 'a' there are two fields 'alias' and 'aid', in 'b' there are
two fields 'category' and 'bid' and in 'c' there are two fields 'aid'
and 'bid' (these fileds contains ids from 'a' and 'b' table where they
matched!

Now what i want to do is to get 'alias' from 'a' table of 'category'
from 'b' table where both tables' ids are matched in third table 'c'
both tables' id are placed in third table 'c'

kindly help me with the solution

database type is MS ACCESS 2003
 
J

John W. Vinson

Hi,
I am having a problem in building this query, here's the situation:

I have 3 tables 'a' 'b' and 'c'
Now in 'a' there are two fields 'alias' and 'aid', in 'b' there are
two fields 'category' and 'bid' and in 'c' there are two fields 'aid'
and 'bid' (these fileds contains ids from 'a' and 'b' table where they
matched!

Now what i want to do is to get 'alias' from 'a' table of 'category'
from 'b' table where both tables' ids are matched in third table 'c'
both tables' id are placed in third table 'c'

kindly help me with the solution

database type is MS ACCESS 2003

Just add all three tables to the query grid.

Join the aid field from A to the aid field in C, and similarly join the bid
field from B to the bid field in B.

Select whichever fields you would like displayed.
 
M

Murtaza

Just add all three tables to the query grid.

Join the aid field from A to the aid field in C, and similarly join the bid
field from B to the bid field in B.

Select whichever fields you would like displayed.

actually i am working on a web project using ms access on backend and
coldfusion, the solution you given me can be used on ms access
program, so can you provide me constructed query so i can than be able
to implement on my page
 
J

John W. Vinson

actually i am working on a web project using ms access on backend and
coldfusion, the solution you given me can be used on ms access
program, so can you provide me constructed query so i can than be able
to implement on my page

Using the table and fieldnames you posted (since I can't guess what the actual
ones might be), and selecting only the fields that you've posted,

SELECT A.Alias, B.Category, <any other fields you like)
FROM (A INNER JOIN C ON A.aid = C.aid)
INNER JOIN B ON B.bid = C.bid;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top