例子:
SELECT country
FROM data
WHERE city LIKE
(SELECT LEFT ('jakartada',7));
它工作得很好但是如果我给定界符 value:4 ,我必须像这样给出通配符 ---> "%string%" ,我可以在查询中给出通配符吗?
使用 LIKE,您可以在模式中使用以下两个通配符。
Character Description
% Matches any number of characters, even zero characters
_ Matches exactly one character
\% Matches one “%” character
\_ Matches one “_” character
此查询对您有帮助吗?
SELECT country
FROM data
WHERE city LIKE CONCAT ('%', (SELECT LEFT ('jakartada',7)), '%');
为什么你使用子查询?
SELECT * FROM `data` WHERE city LIKE 'jakar%'