Friday, March 30, 2012

help with sql query

I am trying to fill a dataset with customers in Table1, but i am searching by ItemID(probably from Table3). I can't figure out the sql query for this request.
Maybe something like:"select * from Table1 ...and now I think I should some how inner join Table1 and Table3 so i can select according to ItemID.

I have the three following tables:

Table1--It's primary key is the CustID identity field:

CustID CustName CustEmail ...

Table2--It's primary key is the ItemID identity field:
ItemID ItemName

Table3--ItemID and CustID function together for the primary key of the table:
ItemID CustID
1 1
2 1
2 2
3 2
1 3
3 3

ThanksTry this


select customers.* from table1, table2,table3 where
table1.custid=table3.custid and table3.itemid=table2.itemid

HTH|||Thanks!

No comments:

Post a Comment