I want search in table
and relationship
Table 1
id title
---------------------
1 kia
2 chevrolet
3 benz
4 bmw
Table 2
id brand
---------------------
1 1
2 3
3 1
4 1
5 2
6 4
7 1
8 3
Result
2,8
If i search benz
, i want show result from table 2
but like from table 1
My code
SELECT * FROM `table2` LEFT JOIN `table1` ON table2.brand=table1.id WHERE table1.title LIKE '%benz%'
But this code not return result
SELECT * FROM table2 WHERE id IN (SELECT id FROM table1 WHERE title LIKE '%benz%');
让我知道这是否对您有用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.