Check if a value is contained in the line

4

I'm working with a query system, and I would like, for example: If I look for the "a" value, it would return all the rows that have "a". I tried using the like command, as shown below:

SELECT * FROM usuario WHERE nome LIKE 'a%';

But it only returns me if the value is at the beginning of the line. How can I check if "a" is contained in the line?

    
asked by anonymous 04.09.2017 / 15:01

1 answer

5

The% is a wildcard that represents "anything". That is, the search is being done by names that start with "a" and have anything later .

You only need to adapt anything before and after from "a".

SELECT * FROM usuario WHERE nome LIKE '%a%';
    
04.09.2017 / 15:02