dflow Posted April 13, 2011 Share Posted April 13, 2011 for example: ID=35 ID=105 Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/ Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 RIGHT() SELECT `id` FROM `table` WHERE RIGHT(`id`, 1) = 5 Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201112 Share on other sites More sharing options...
dflow Posted April 13, 2011 Author Share Posted April 13, 2011 RIGHT() SELECT `id` FROM `table` WHERE RIGHT(`id`, 1) = 5 thanks Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201113 Share on other sites More sharing options...
dflow Posted April 13, 2011 Author Share Posted April 13, 2011 ok it works in the phpmyadmin but when i intergrate it with : SELECT * FROM apartments WHERE InternalSupplierID ='1' AND country_id = '20' AND city_id = '2' and Desc <>'' and RIGHT( 'ID',1 ) =5 i get empty results although i see results without " RIGHT( 'ID',1 ) =5" in the query that should match Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201144 Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 You're using single quotes around 'id'. Those should either be replaced with `backticks` or simply removed. Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201145 Share on other sites More sharing options...
dflow Posted April 13, 2011 Author Share Posted April 13, 2011 ok it works in the phpmyadmin but when i intergrate it with : SELECT * FROM apartments WHERE InternalSupplierID ='1' AND country_id = '20' AND city_id = '2' and Desc <>'' and RIGHT( 'ID',1 ) =5 i get empty results although i see results without " RIGHT( 'ID',1 ) =5" in the query that should match You're using single quotes around 'id'. Those should either be replaced with `backticks` or simply removed. cheers again Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201148 Share on other sites More sharing options...
Pikachu2000 Posted April 13, 2011 Share Posted April 13, 2011 desc is a MySQL reserved word. Either enclose it in `backticks`, or rename the column. You should be checking for query failure, and using mysql_error() while developing . . . Link to comment https://forums.phpfreaks.com/topic/233602-how-to-query-ids-ending-with-5-in-the-ones-digit/#findComment-1201153 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.