Home > Software engineering >  Query mysql to get data based on some characters from the contents of a column?
Query mysql to get data based on some characters from the contents of a column?

Time:07-26

I want to do a query on a MySQL database to get data from a column based on some characters from that column. For example in the name column, there are many names, I want to get data with names starting with 'AN' or 'AB'. Hope someone can help me. Thank you

CodePudding user response:

It would be better if you could show some examples of what you have and what you want as your result.

A simple LIKE should work for you with a % wildcard at the end.

SELECT
*
FROM
table_name t
where t.<name_column> like 'AN%' OR t.<name_column> like 'AB%'

Did you try this?

CodePudding user response:

Like Operator is used to perform this operation Query: Select * from table-name where name like 'AN%'

  • Related