If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > how do i query a m to n (many to many) relationship?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-28-04, 14:10
rollbond rollbond is offline
Registered User
 
Join Date: Jan 2004
Location: canada, germany
Posts: 2
Cool how do i query a m to n (many to many) relationship?

hey guys

i have the following problem:

table 1(movie) contains:
movieID movie
---------------------------
00128 bad boys

table2(actor)
actorID actor
------------------------------------
004 will smith
005 martin lawrence

table3(actorConnect)
acConID movieID actorID
------------------------------------
0011 00128 004
0012 00128 005


how do i code, if i want the following output:

movie actor actor
--------------------------------------------------
bad boys will smith martin lawrence

thanks in advance
Reply With Quote
  #2 (permalink)  
Old 01-28-04, 14:20
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
presumably you know how to join the tables to get this result, yes?

movie actor
bad boys will smith
bad boys martin lawrence

"flattening" (or denormalizing) the result set is purely cosmetic, and is best done by your scripting language

there is no simple sql that will do it for you, except in sybase ase (LIST) or mysql version 4.1 (GROUP_CONCAT)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-30-04, 12:20
rollbond rollbond is offline
Registered User
 
Join Date: Jan 2004
Location: canada, germany
Posts: 2
Arrow Re: how do i query a m to n (many to many) relationship?

ok, thanks

i will try
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On