Brandon Brandon - 2 months ago 7
MySQL Question

Any way to select from MySQL table where a field ends in certain character/number?

I am hoping to run a mysql_query where I can select a row if a certain field ends in a number. For example:

<?php
$query = mysql_query("SELECT id FROM table WHERE [ID ENDS IN 0]");
$query = mysql_query("SELECT id FROM table WHERE [ID ENDS IN 1]");
$query = mysql_query("SELECT id FROM table WHERE [ID ENDS IN 2]");
$query = mysql_query("SELECT id FROM table WHERE [ID ENDS IN 3]");
//and so on...
?>


Is there a way to do this? Any help would be great. Thank you!

Answer
SELECT ...
  WHERE somefield LIKE '%1'
Comments