A SELECT that pulls rows from a column (string; string)

1

>

Example, in a certain column I have the values:

1) (joana; carla; josefa)

2) (gabriela; maria; julia)

3) (maria; carol; jaqueline)

SELECT needs to return the lines of 2 and 3 that have "maria"

I need to do a php filtering and list certain data from these lines

    
asked by anonymous 02.11.2017 / 04:28

1 answer

1

So I understand you have a varchar field and need to find in it, any name that contains a certain value, you can use the like plus % command.

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. Example:

SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;

Another possibility to be explored is the use of the _ operator. This defining any character, for example:

WHERE CustomerName LIKE '_r%'

You will search for any word with r in the second position. It can be used in several ways so you can see more here .

Having said all these concepts, the way to solve your problem would be select with like simple:

select * from TABELA where CAMPO LIKE '%maria%'
    
16.11.2017 / 17:01