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. Link to comment https://forums.phpfreaks.com/topic/111693-solved-help-with-a-query/ 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%' Link to comment https://forums.phpfreaks.com/topic/111693-solved-help-with-a-query/#findComment-573313 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? Link to comment https://forums.phpfreaks.com/topic/111693-solved-help-with-a-query/#findComment-573333 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. Link to comment https://forums.phpfreaks.com/topic/111693-solved-help-with-a-query/#findComment-573431 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? Link to comment https://forums.phpfreaks.com/topic/111693-solved-help-with-a-query/#findComment-573478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.