使用MySQL查询显示品牌

I have 3 MySQL tables:

  • produs(id, name, price)
  • spec_laptop(id,id_produs -foreigkey(produs-id), brand)
  • spec_telefon(id,id_produs -foreigkey(produs-id), brand)

and 2 pages:

  • telefon.php (which will have a list of brands of cellphones)
  • laptop.php (which will have a list of brands of laptops)

    I tried to make a query which displays names and prices from produs which:

    1. When I click a brand from telefon.php , display all cellphones names and prices who have that brand
    2. When I click a brand from laptop.php , display all laptops names and prices who have that brand

Example: (it doesn't work and I don't know why):

SELECT t1.*,t2.*,t3.* FROM produs as t1 join spec_laptop as t2  join spec_telefon as t3 WHERE(t1.id=t3.id_produs OR t1.id=t2.id_produs) AND t2.brand='Acer'

You joined them the wrong way, try this one :

SELECT * FROM produs as t1
inner join spec_laptop as t2 ON t2.id_produs = t1.id
inner join spec_telefon as t3 ON t3.id_produs = t1.id
WHERE t2.brand='Acer'