SELECT * FROM tbl WHERE clm LIKE CONCAT ('%', <other sql query LIMIT 1>, '%') - HOW?
How to combine these two queries into one?
1) This finds the Japanese sign for the dog (犬):
SELECT japanese
FROM edict
WHERE english LIKE 'dog'
LIMIT 1;
2) This finds all Japanese words with the sign “dog” (犬) in it:
SELECT japanese
FROM edict
WHERE japanese LIKE '%犬%';
3) I had problems combining the two into one, because it doesn’t work ?!
SELECT japanese
FROM edict
WHERE japanese
LIKE CONCAT('%',
SELECT japanese FROM edict WHERE english LIKE 'dog' LIMIT 1,'%'
);
+5
2 answers
Using:
SELECT a.japanese
FROM EDICT a
JOIN EDICT b ON b.japanese = a.japanese
WHERE b.english LIKE 'dog'
I do not recommend using LIMIT, but if you really need it, 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
+4