Check if a value is contained in the line

Asked

Viewed 339 times

4

I am working with a query system, and I would like that, for example: If I look for the value "a", it returns me all the lines that have "a". I tried to use the command like, 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?

  • 3

    Would not be '%a%?

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 after.

You just have to adapt to anything before and after of "the".

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.