JSHINER Posted June 24, 2008 Share Posted June 24, 2008 In my table I have a field that contains "0494,0501,5081" - how can I run a query that will return that row if $desiredNum = "0501" (or any of the numbers contained within that field. Quote Link to comment Share on other sites More sharing options...
nashruddin Posted June 24, 2008 Share Posted June 24, 2008 use LIKE operator. ex: SELECT * FROM tableName WHERE columnName LIKE '%$desiredNum%' Quote Link to comment Share on other sites More sharing options...
JSHINER Posted June 24, 2008 Author Share Posted June 24, 2008 That does not work since almost all have ",0" in them so it always returns true. Is there a way to do this? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 24, 2008 Share Posted June 24, 2008 You can use FIND_IN_SET() if they are comma separated. Quote Link to comment Share on other sites More sharing options...
JSHINER Posted June 24, 2008 Author Share Posted June 24, 2008 They are comma separated - how would I work that into the query? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.