Jump to content

[SOLVED] MySQL IN? Or is something better?


Boo-urns

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/166215-solved-mysql-in-or-is-something-better/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.