...

View Full Version : INNER JOIN to join two tables how I can use a filter



lse123
08-02-2007, 05:58 PM
When I use INNER JOIN to join two tables how I can use a filter: two fields one in the first and another in the second table to equal two vars [tell me an example] ?
this is correct: SELECT table1.name, table1.address, table2.AID FROM table1 INNER JOIN table2 ON table1.name='" & Name & "' AND ON table2.AID='" & ID & "'"

nbcrockett
08-02-2007, 07:02 PM
Is there a field that's the same in both tables?

miranda
08-02-2007, 10:23 PM
Inner joins Must have a field that has a common value in both tables. They look like something this

SELECT table1.name, table1.address, table2.AID FROM table1 INNER JOIN table2 ON table1.name=table2.name WHERE table1.name='" & Name & "' AND table2.AID='" & ID & "'"


IN SQL SERVER or Oracle you can also use

SELECT table1.name, table1.address, table2.AID FROM table1, table2
WHERE table1.name = table2.name AND table1.name='" & Name & "' AND table2.AID='" & ID & "'"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum