Hi,
how do i join 2 tables based on a third "index" table
for example, i have one table with buyer name and buyer id, one table with seller name and seller id, and a third table with user id and buyer id
how do i get a list of buyer name and seller name, using table 3?
thanks
SQL Joins
Moderator: General Moderators
- Peter Anselmo
- Forum Commoner
- Posts: 58
- Joined: Wed Feb 27, 2008 7:22 pm
Re: SQL Joins
Can you describe how the user table relates to the seller table? The database design isn't clear from your description.
Re: SQL Joins
I believe you want something like this:
Code: Select all
SELECT
b.name AS buyer_name,
s.name AS seller_name
FROM
buyer b,
seller c,
buy2sell bs
WHERE
b.id = bs.id
AND bs.id = c.id