Boo-urns Posted July 16, 2009 Share Posted July 16, 2009 Basically what i have is one table of goals (id, goalName, etc...) In the other table for the users I have (id, name, goal_ids) Where there can be multiple goal ids in the column. First question is that a good way to set it up. Second question is I have a form that you can search goals on, so I'm looking for a user with goal ids of 1 and 2. I've tried IN and it works great for searching for 1 id, but when i throw in another it WILL pull it, but it also pulls rows with just 1 of the ids as well. Any suggestions?! Thanks, Corey Quote Link to comment https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 16, 2009 Share Posted July 16, 2009 multiple goal ids in the column ... is that a good way to set it up No it's not. It makes directly searching impossible and it also makes all the other queries to store and retrieve the data more complicated and slow. Use a separate row for each entry. Quote Link to comment https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/#findComment-876508 Share on other sites More sharing options...
Boo-urns Posted July 16, 2009 Author Share Posted July 16, 2009 So if the user has 2 goals.... I need 2 rows for that user? Quote Link to comment https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/#findComment-876515 Share on other sites More sharing options...
kickstart Posted July 16, 2009 Share Posted July 16, 2009 Hi Yep. Have a table of users, and a table of goals. On the table of goals one row per goal. The use a JOIN to get a list of users and their goals. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/#findComment-876534 Share on other sites More sharing options...
Boo-urns Posted July 16, 2009 Author Share Posted July 16, 2009 Thanks guys! I was hoping there was a faster way around it, but sometimes shortcuts are dangerous! Thanks for the guidance! Quote Link to comment https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/#findComment-876538 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.