How do I search for records that fit into any category in a list, even if the category name only partially matches? [duplicate]

1

I have this statement:

$nova   = (explode('/', implode('/', $_GET['tipo'])));

What results in this array:

Array
(
    [0] => CONJUNTO
    [1] => SALA
    [2] => LOJA
)

When I do this query in my database ...

$sql = "SELECT * FROM imovel WHERE CATEGORIA IN ('".implode("','", $nova)."')";

... it only returns me the results of LOJA and I know why, because CONJUNTO and SALA are inside a single string, like this: CONJUNTO/SALA , then how it looks for the statement Exact does not bring me these results.

One of the SQL statements allows me to also bring results containing these indexes by approximate comparison which in this case will be perfect.

Help me apply this statement to this $sql ??

    
asked by anonymous 04.10.2014 / 14:49

1 answer

3

It seems to me that you are wanting the so-called "Pattern Matching". Try using the SQL LIKE clause

$sql = "SELECT * FROM imovel WHERE CATEGORIA LIKE ('%CONJUNTO%')";

link

Documentation: link

    
04.10.2014 / 14:58