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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.