Take the 2-minute tour ×

I have 2 Tables in phpmyadmin that need joining

tracklisting is my one and catelogue is the other, and are saved as innodb

They both have a column CAT.NO and would like it to be joined on this column. In catelogue it is the primary and in tracklisting it's indexed

catelogue is my parent and tracklisting would be the child as it doesn't have info for every record in catelogue. I believe this would be correct unless I'm wrong

How do I do this so that when I query on a column in tracklisting it only brings up the matches for 'catelogue' because I want to know what album it's on and not my entire 60000+ catelogue

Can this be done with phpmyadmin's interface or is this a sql statement

Many thanks


This was the code that worked

FROM tracklisting
INNER JOIN catelogue ON catelogue.`CAT NO.` = tracklisting.`TRACKLISTING CAT NO.`
WHERE tracklisting.`ARTIST` LIKE 'placebo'

Thanks to everyone that helped out

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

I dont know if this can be done with the interface, but with sql

  tracklisting t 
  INNER JOIN catelouge c on c.catno=t.catno 
WHERE t.id = 1
share|improve this answer
Just needed a bit of editing to match all my columns but that is what i wanted. O and the where clause changed to my search criteria –  Mark Jan 3 '12 at 7:40
add comment

Assuming that your tracklisting has an id and you want to query with it:

select * from tracklisting t
inner join catelogue c on c.cat.no = t.cat.no
where t.id = 1
share|improve this answer
add comment

You can query with a LEFT JOIN:

SELECT * FROM tracklisting LEFT JOIN catelogue ON tracklisting.`CAT.NO` = catelogue.`CAT.NO` WHERE tracklisting.`<id-field>` = <id-value>`


share|improve this answer
add comment

The actual join takes place in a SQL statement although with certain storage types like InnoDB you can also create foreign key references that enforce the relationship at the database level so that your inserts require the proper records to be in place and your deletes are restricted if child records exist.

Here is one way of doing the join syntax for your SQL query:

SELECT t.* FROM tracklisting t, catalogue c

EDIT: Here is a link to a tutorial for creating foreign keys in phpMyAdmin.

share|improve this answer
If I setup a Foreign key will phpmyadmin be able to create the sql code i'm looking for or will that still have to be entered in manually? –  Mark Dec 31 '11 at 10:57
Unfortunately, no, phpMyAdmin won't create the join code for you based on the foreign keys. Some PHP frameworks will do the work for you such as CakePHP and others. In those frameworks if you have the foreign key relationships configured then the framework does all the necessary joining in the queries. –  davidethell Dec 31 '11 at 11:12
add comment

Your Answer


