Reputation: 3
Yo.
I want to find two first names such as 'name1' 'name2' in a column which contains both firstname and lastname.
WHERE ContactName IN ('name1%', 'name2%'); <-- doesn't work with wildcards
How do I do it?
Upvotes: 0
Views: 62
Reputation: 6134
you should refer this link CLICK HERE:
.......WHERE ContactName LIKE 'name1 %' OR ContactName LIKE 'name2 %';
Upvotes: 0
Reputation: 18600
Try this
SELECT * FROM tbl_name
WHERE ContactName LIKE "name1%" OR ContactName LIKE "name2%";
Upvotes: 0
Reputation: 22646
One alternative is to list each individually and use LIKE
WHERE ContactName LIKE 'name1 %' OR ContactName LIKE 'name2 %';
Note that I've added a space after the name. I assumed you want an exact match on the first name.
Alternatively you could use MySQL REGEXP
function:
WHERE ContactName REGEXP '^(name1|name2)$'
Upvotes: 1
Reputation: 2192
try
where Match(ContactName ) Against ('name1', 'name2')
but before that make sure that you have Full text Index created on name field.
Upvotes: 1