
May 19th, 2006, 06:09 PM
|
|
Registered User
|
|
Join Date: May 2006
Posts: 2
Time spent in forums: 21 m 13 sec
Reputation Power: 0
|
|
|
Please help with a simple many-to-many join query
Hi,
I have two tables (a and b) with a many-to-many relationship defined by a 'link_table'. Given an id for table b (33 in the example below), I want to use a join to retrieve the corresponding records in table a. I've tried the query below (which looks right to me), but i'm not getting any records returned (using MySQL 4.0.18 and InnoDB).
Pleeease help.
Here's the query:
SELECT a.fld1, a.fld2, a.fld3
FROM long_tablename_a
AS a
JOIN link_table
ON link_table.a_id='33'
AND link_table.a_id = a.id
WHERE 1 = 1;
Thanks.
|