简体   繁体   中英

using LIKE %% with LEFT JOIN

Ok, i used "LIKE" with "LEFT JOIN" and it works fine.

$sql = $conn->query("SELECT * FROM tasks t 
                     LEFT JOIN users u 
                     ON t.allowed_countries LIKE u.country 
                     WHERE u.username = '$username'");

but when i'm try to use "LIKE %%" instead of using "LIKE" then it gives me error

LIKE '%" u.country "%'

Can anybody tell me the problem please?

Thank you.

USE concat as%是一个char字面值。

LIKE concat('%',u.country,'%')

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM