RE: three-way join

2002-01-24 Thread Roger Baklund
* mike vogel > thanks to all respondents! one more thing, i have 2 foreign keys in the > bridge table, but not a primary key. is a primary key in the bridge > necessary for this type of join to work? thanks again. Make the two foreign keys the primary key for this table, that way you prevent the

RE: three-way join

2002-01-23 Thread Roger Karnouk
create table magazine (Mag_id int primary key, Name char(30)); create table customer (cust_id int primary key, name char(30)); create table bridge (cust_id int not null, mag_id int not null, primary key(mag_id,cust_id)); insert into customer values (10,'John'),(24,'Luke'),(43,'Tony'),(25,'Ma

RE: three-way join

2002-01-23 Thread Roger Baklund
* mike vogel > i understand that creating a M:N relationship in mysql involves 3 > tables, one of which being a bridge, but how do i join the first and > third tables by way of a bridge? The same way you do a M:1 'bridge', but one single table is the M-part of both 'bridges'. > example: a tab

Re: three-way join

2002-01-23 Thread Christopher Thompson
Thanks, David. He is of course correct if you need to look up the name of the subscriber. If you already know the subscriber's ID, you can modify the query to look more like mine. In any case, try to avoid large joins. :) At 03:08 PM 1/23/2002 -0800, David Turner wrote: >Sorry not real fami

Re: three-way join

2002-01-23 Thread David Turner
Sorry not real familar with MYSQL syntax yet but I think you'll be able to translate. select m.magazinename from s,m,b where s.name = 'fred' and s.id=b.subscriberid and m.id=b.magazineid ; On Wed, Jan 23, 2002 at 03:59:11PM -0700, Christopher Thompson wrote: > At 02:51 PM 1/23/200

Re: three-way join

2002-01-23 Thread Christopher Thompson
At 02:51 PM 1/23/2002 -0800, you wrote: >i understand that creating a M:N relationship in mysql involves 3 tables, >one of which being a bridge, but how do i join the first and third tables >by way of a bridge? > > example: a table of subscribers and a table of magazines with a bridge > in th