SELECT * FROM tbl WHERE clm LIKE CONCAT('%',<other sql query LIMIT 1>,'%') - HOW?
How can I combine those two queries into one?
1) This finds the japanese sign for dog (犬):
SELECT japanese
FROM edict
WHERE english LIKE 'dog'
LIMIT 1;
2) This finds all japanese words with the sign for 'dog' (犬) in it:
SELECT japanese
FROM edict
WHERE japan开发者_运维知识库ese LIKE '%犬%';
3) I am having trouble combining those two into one, because this doesn't work?!
SELECT japanese
FROM edict
WHERE japanese
LIKE CONCAT('%',
SELECT japanese FROM edict WHERE english LIKE 'dog' LIMIT 1,'%'
);
Parenthesises are important, therefore, try this :
SELECT japanese
FROM edict
WHERE japanese LIKE CONCAT('%',
(SELECT japanese FROM edict WHERE english LIKE 'dog' LIMIT 1),
'%');
It might have been good to tell us what error you received, though.
Use:
SELECT a.japanese
FROM EDICT a
JOIN EDICT b ON b.japanese = a.japanese
WHERE b.english LIKE 'dog'
I don't recommend the use of LIMIT, but if you really need it for this, use:
SELECT a.japanese
FROM EDICT a
JOIN (SELECT t.japanese
FROM EDICT t
WHERE t.english LIKE 'dog'
LIMIT 1) b ON b.japanese = a.japanese
精彩评论