* 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 table of subscribers and a table of magazines with a bridge > in the middle. how do i select just the magazines fred is subscribed to? The third table must include the primary key from both the subscriber table and the magazine table, let's call the table 'subscriptions' and the two forreign keys 'subs_id' and 'mag_id'. The subscriptions table should have (subs_key,mag_id) as a unique index, it could be the primary key for the table. The table could also include other information related to the subscriptions, like start_date, last_payment and so on. If you want fred's subscriptions: select magz.name,subs.start_date,subs._last_payment from subscribers as pers, subscriptions as subs, magazines as magz where pers.name = 'fred' and subs.subs_id = pers.subs_id and magz.mag_id = subs.mag_id; Normally you would probably find the subs_id of fred in a separate query... but I enjoy writing joins so much, so I included it just for fun. :) I see you have got several answers to this question already, so I suppose you are helped. :) -- Roger --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php