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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement problem 1

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
firstly i cant change the structure of the tables.

its an Access2000 DB, i have 3 tables tableA containing 2 fields (TableAID,TableAString) tableB again containing 2 fields (TableBID,TableBString) then tableLink containing 3 fields (TableLinkID,TableAID,TableBID)

(i think this is set out this way to get a many-many relationship?!)

anyway, i need to select values from TableB, based on the selected item in a combobox (which relates to tableA)

ive done a similar kind of thing using INNER JOIN but that was only on 2 tables, can anyone get me started on this, its doing my tree in

something like:-

"SELECT * FROM tableB INNER JOIN tableLink ON TableB <something here?> WHERE TableAID=cmbTableA.Value"

any help realy appreciated

If somethings hard to do, its not worth doing - Homer Simpson
 
Code:
SQL = _
"Select * " & _
"From TableB As B INNER JOIN TableLink As L " & _
"     ON B.TableBID = L.TableBID " & _
"Where L.TableAID = " & cmbTableA.Value & " "
Assuming that TableAID is numeric. If it's text then you would need

"Where L.TableAID = '" & cmbTableA.Value & "'"
 
ty so much... that works

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top