MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 19th, 2006, 06:09 PM
stephenrs stephenrs is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 2 stephenrs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old May 19th, 2006, 09:28 PM
stephenrs stephenrs is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 2 stephenrs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 13 sec
Reputation Power: 0
Problem sovled

My problem wasn't the query...it was the fact that the key on table a was a varchar, not an int...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Please help with a simple many-to-many join query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway