我希望左连接到其他表格并且喜欢
我的代码:
SELECT *
FROM `offer`
LEFT JOIN `category` ON (category.id=offer.brand OR category.id=offer.model)
WHERE offer.active='1' AND `finish`='0' AND
(category.title LIKE '%2013%' OR category.title_en LIKE '%2013%' OR
offer.year LIKE '%2013%')
GROUP BY offer.id
ORDER BY `last_update` DESC LIMIT 0, 10
优惠表:
id year brand model
------------------------------------
1 1390 1 2
2 2050 2 3
3 2010 1 4
4 2200 4 1
类别表
id title title_en
------------------------------------
1 kia kia_url
2 optima optima_url
3 name name_url
4 benz benz_url
运行我的代码和LIKE BENZ后,我想从OFFER表中返回ID 4