love_bug Posted January 13, 2009 Share Posted January 13, 2009 Hi, This is an unusual problem I have.. I have a field named "recipient_userids" where I store ids of users in a comma separated form, sucha as "3323,5543,53,3235,23" Now I want to select records from db, which matches a particular userid in "recipient_userids". such as.. If I want to retrieve a record that has 53 in "recipient_userids" how do I do it? I tried LIKE, IN syntax, but not doing the job. OR is there a way to do it please share. Quote Link to comment https://forums.phpfreaks.com/topic/140696-solved-querying-comma-separated-field-array/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2009 Share Posted January 13, 2009 That's because a comma separated list in a database is only really usable if you want to store and retrieve that list and you don't expect to process the list using the database. It is not possible to reliably search (for example searching for '55' would match '5543') or sort using that list. The correct method if you want to search or sort the items in a list is to use a table design that stores each item in a separate row. Quote Link to comment https://forums.phpfreaks.com/topic/140696-solved-querying-comma-separated-field-array/#findComment-736478 Share on other sites More sharing options...
love_bug Posted January 13, 2009 Author Share Posted January 13, 2009 thanks 4 help.. Quote Link to comment https://forums.phpfreaks.com/topic/140696-solved-querying-comma-separated-field-array/#findComment-736482 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.