David
David

Reputation: 14414

Problem matching strings with MySQL

I am having trouble matching strings in MySQL. I have the following:

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 

I would like to filter the above results even further by adding ea.title='%tele%' to the above sql statement like the following

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 

The above sql statement doesn't return anything, however when I do the following I get a result.

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 

Any suggestions on what I might be doing wrong?

Upvotes: 1

Views: 75

Answers (2)

Jacob Eggers
Jacob Eggers

Reputation: 9332

I believe you want LIKE

ea.title LIKE '%tele%'

Upvotes: 2

joekrell
joekrell

Reputation: 341

Change it to

ea.title LIKE '%tele%'

Upvotes: 3

Related Questions