我正在使用带有 like 子句的内部连接 ..
我试过的sql是
SELECT tbl_songs.id AS sid,
tbl_songs.name AS sname,
tbl_albums.id AS aid,
tbl_albums.name AS aname
FROM tbl_songs
INNER JOIN tbl_albums
ON tbl_songs.albums LIKE '%' + tbl_albums.name + '%';
它向我显示语法错误。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+ tbl_albums.name + '%'' at line 2
请详细说明语法错误的原因。
最佳答案
你必须使用 concat ... 形成子句
...LIKE CONCAT('%',tbl_albums.name, '%');
mysql中没有这样的+
操作符
关于mysql - 内部加入 like 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17003165/