JOIN on composite primary key (mysql)

Soldato
Joined
24 Nov 2002
Posts
16,378
Location
38.744281°N 104.846806°W
I have two tables:

db_refs_link
prints_id, id*, db*

and

db_refs
id*, db*, desc

*Composite primary key.

I'd like to join these two tables on the composite primary key.

1) SELECT * FROM `db_refs` JOIN `db_refs_link` ON `db_refs`.id= `db_refs_link`.id

2) SELECT DISTINCT * FROM `db_refs` JOIN `db_refs_link` ON `db_refs`.id= `db_refs_link`.id AND `db_refs`.db= `db_refs_link`.db

2) doesn't work and 1) yields too many (and wrong) results.

Any ideas?

:(
 
Back
Top Bottom