Search code examples
mysqlsqlwhere-clausesql-like

USE % WILD IN WHERE CLAUSE


I have a record in my MySQL database which is a varchar type for e.g

 john;john;john;jack;jack;steve;steve

I am running a query to fetch this record, say the column name is NAME and table name is DATA. so my query is .........

SELECT * FROM DATA WHERE NAME LIKE '%john;jack;steve%' 

But this query isn't fetching any record

Tell me any possible way to fetch this particular record through this '%john;jack;steve%'


Solution

  • Table data doesn't match what you are searching for.

    What you can do is, separate each name as different conditions:

    SELECT * 
    FROM DATA 
    WHERE NAME LIKE '%john%'
       AND NAME LIKE '%jack%'
       AND NAME LIKE '%steve%'