Please help me with the query:
There is a table of brands in which the brand_id, parent_id and brand_name fields are stored. There are both parents of the brand and their children.
There is a table of goods in which the goods_brandid and brand_sort fields are stored. That is, goods_brandid = brand_id from the brands database.
Actually the question itself is how to get all the brand_sort out of the goods table, where is their parent_id = 3, for example?
I tried to pull it out like this, but it still displays all the values:
SELECT goods.brand_sort, brands.parent_id FROM goods, brands WHERE brands.parent_id = '3'
Update
Thank you all very much, made a little differently:
SELECT goods.brand_sort FROM goods LEFT JOIN brands ON (brands.brand_id = goods.goods_brandid) WHERE brands.parent_id = '3' GROUP BY `brand_sort` ;)