How to join this table?

Posted by pamella on Stack Overflow See other posts from Stack Overflow or by pamella
Published on 2010-12-22T04:18:26Z Indexed on 2010/12/22 5:54 UTC
Read the original article Hit count: 157

Filed under:

ads table
img90.imageshack.us/img90/6295/adsvo.png

phones table
img194.imageshack.us/img194/3713/phones.png

cars table
img35.imageshack.us/img35/1035/carsm.png

i have 3 tables ads,cars and phones.

i want to join tables is based on category in ads table.

and i tried this query but no luck,any helps?

SELECT *
  FROM `ads` 
  JOIN `ads.category` ON `ads.id` = `ads.category.id`

** i cant add comment any of your post,but i want it to be automatic based on category in ads table.

for example :- if in table have phones category,i will automatic join phones table then

SELECT *
  FROM `ads` 
  JOIN `phone` ON `ads.id` = `phone.id`

if in table have cars category,i will automatic join cars table

SELECT *
  FROM `ads` 
  JOIN `cars` ON `ads.id` = `cars.id`

© Stack Overflow or respective owner

Related posts about mysql