Computing.Net > Forums > Database > Many to Many query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Many to Many query

Reply to Message Icon

Name: ShaqDiesel
Date: July 3, 2008 at 21:24:51 Pacific
OS: winXP
CPU/Ram: Amd64/1Gb
Product: custom
Comment:

I have a many to many relationship of titles and authors. I have a table of authors, another for titles, and a junction table. For a given title, how would I extract ALL the authors? I don't want multiple rows for the same title.



Sponsored Link
Ads by Google

Response Number 1
Name: dotnet_ohio
Date: July 16, 2008 at 19:38:05 Pacific
Reply:

It depends on your database. I am not 100% sure on MySQL, but in Access or SQL 200x you can use a left join / right join command in the from clause. The left join (and there are forums - just search google for left join / right join) that will tell you the exact details.

Also, a trick I used to do was link the tables in Access. Then in the actually do the query with the design view in access. After you make the join between the tables, just select all from table titles to table authors. If you click over to the SQL view, it will actually create the query for you. Note, you can't just cut and paste this as is, you will have to format it for whatever language you have. Also, I'm not sure if this will work with MySQL.

http://www.dotnetohio.com


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Many to Many query

How to edit query in MS Access using batch www.computing.net/answers/dbase/how-to-edit-query-in-ms-access-using-batch/682.html

Optimize the SQL www.computing.net/answers/dbase/optimize-the-sql/734.html

Merging DB's in Access www.computing.net/answers/dbase/merging-dbs-in-access/34.html