我在MySQL中匹配字符串时遇到问题。我有以下内容:
SELECT ea.*
FROM epf_application ea
JOIN epf_application_device_type ead ON ea.application_id = ead.application_id
JOIN epf_device_type edt ON ead.device_type_id = edt.device_type_id
WHERE
edt.name = 'someDevice'
LIMIT 30
我想通过将ea.title='%tele%'
添加到上面的sql语句中来进一步过滤上述结果,如下所示
SELECT ea.*
FROM epf_application ea
JOIN epf_application_device_type ead ON ea.application_id = ead.application_id
JOIN epf_device_type edt ON ead.device_type_id = edt.device_type_id
WHERE
edt.name = 'someDevice' AND ea.title='%tele%'
LIMIT 30
上面的sql语句没有返回任何内容,但是当我执行以下操作时,我得到了一个结果。
SELECT ea.*
FROM epf_application ea
JOIN epf_application_device_type ead ON ea.application_id = ead.application_id
JOIN epf_device_type edt ON ead.device_type_id = edt.device_type_id
WHERE
edt.name = 'someDevice' AND ea.title='television'
LIMIT 30
有关我可能做错的任何建议吗?
答案 0 :(得分:3)
将其更改为
ea.title LIKE '%tele%'
答案 1 :(得分:2)
我相信你想要LIKE
ea.title LIKE '%tele%'