Result equal to the last two characters of the records

Asked

Viewed 26 times

0

I tried to create an SQL for MYSQL to query only the records containing the last two characters, I did so:

<?php
$query = "SELECT * FROM `veiculos` WHERE `placa` LIKE '07%' ORDER BY `modelo` ASC;
?>

But SQL ignores the LIKE does not display any record, no errors, just does not display.

[EDITED]

Then I changed the position of LIKE and appeared the record, only one, but the other doubt that arose is, and if there is more than one record for example XXX-0077, SQL will return it too?

<?php
$query = "SELECT * FROM `veiculos` WHERE `placa` LIKE '%07' ORDER BY `modelo` ASC;
?>

1 answer

1


'%07' will only return records finished with '07'.

If the size is fixed, you can also look how the underscore works ( _ ).

If you want any record that has '07' (Example XXX-0077), use '%07%'.

Browser other questions tagged

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