select `id`, `title`, `slug`, `label`, `price`, `old_price`, `category_id`, `picture_id`, `brand_id`
from `products` where
`brand_id` IN (select id from `brands` where `title` like '%лампа%' or `tags` like '%лампа%')
OR `title` like '%лампа%'
group by `products`.`id`
order by `products`.`sales` desc, `products`.`views` desc
limit 18