Query for Search Field

Asked

Viewed 51 times

0

I need to make a query to search all records that have the term typed in a input, for example: Car, be returned blue car, green car, etc...

My query current:

$query = "SELECT * FROM veiculos WHERE nome = '$veiculo'";

Thank you

  • $query = "SELECT * FROM veiculos WHERE nome LIKE '%$veiculo%'";

  • Thank you, it worked perfectly.

1 answer

0


You can use the operator LIKE. Your query would look this way:

"SELECT * FROM veiculos WHERE nome LIKE '%$veiculo'%"; 

See more details in the documentation.

  • Thank you, it worked perfectly.

Browser other questions tagged

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