fraser5002 Posted July 4, 2011 Share Posted July 4, 2011 Hi i have the following query for my database. $query = "SELECT * FROM entries WHERE id = '$u'"; Is there anyway i can alter this to use all but the last 3 characters from "id" for the query ( will need to obviously determine the length of id for this entry in the database first ) i.e similar to the operation of the php statement substr() Any Ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/241092-query-using-subset-of-string/ Share on other sites More sharing options...
ebmigue Posted July 5, 2011 Share Posted July 5, 2011 $query = "SELECT * FROM entries WHERE LEFT(id, LENGTH(id) - 3) = '$u'"; Hope it helps. Link to comment https://forums.phpfreaks.com/topic/241092-query-using-subset-of-string/#findComment-1238411 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.