小编典典

SELECT * FROM tbl WHERE clm LIKE CONCAT('%',,'%') - 如何?

sql

如何将这两个查询合并为一个?

1)找到狗(钟 )的日本符号:

SELECT japanese 
  FROM edict 
 WHERE english LIKE 'dog' 
 LIMIT 1;

2)在其中找到所有带有’dog’(钟 )符号的日语单词:

SELECT japanese 
  FROM edict 
 WHERE japanese LIKE '%鐘�%';

3)我无法将这两者合而为一,因为这行不通?!

SELECT japanese 
FROM edict 
WHERE japanese
LIKE CONCAT('%',
    SELECT japanese FROM edict WHERE english LIKE 'dog' LIMIT 1,'%'
);

阅读 294

收藏
2021-03-23

共1个答案

小编典典

括号很重要,因此,请尝试以下操作:

SELECT japanese
FROM edict
WHERE japanese LIKE CONCAT('%', 
                           (SELECT japanese FROM edict WHERE english LIKE 'dog' LIMIT 1), 
                           '%');

不过,最好告诉我们您收到了什么错误。

2021-03-23