SELECT `b`.* FROM
`magazine-brands` `b`,
`magazine-categories` `c`,
`magazine-product_brands` `pb`,
`magazine-product_categories` `pc`
WHERE (`c`.`parent`=25)
AND (`pc`.`category` = `c`.`id` AND `pb`.`product` = `pc`.`product` AND `b`.`id` = `pb`.`brand`)
GROUP BY `b`.`id`
SELECT b.*
FROM magazine -brands AS b
INNER JOIN magazine -product_brands AS pb ON pb.brand = b.id
INNER JOIN magazine -product_category AS pc ON pc.product = pb.product
WHERE pc.category = #ID ИСКОМОЙ КАТЕГОРИИ#