Faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 14 people (29%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

Can I have two IDs link to one record in a joining table?

Jan 28th, 2000 15:07
Matt Gregory, Chris N,


No, mySQL does not allow you to do this.
Instead, try using your sql to handle the joins via a concatiniated id 
number.
exmaple:
Categories:
ID #1 = Bar
ID #2 = Club
ID #3 = Restauraunt
Dave And Busters category ID# would be 231 since it is mostly a club 
with a restraunt but does have a bar as well.  Then, when doing a 
search for bars execute 3 queries, listing all 1xx IDs first, since 
their primary category is bar, then run on x1x and then on xx1 and you 
have everything which is a bar listed by priority (plus whatever else 
you order on.)  This should give you the effect you are looking for.