Jump to content

MySQL noob... Please help...


ChaosKnight

Recommended Posts

I'm a complete noob when it comes to databases,

in the project that I'm busy with there is a column

which is filled with a lot of game parks and they are

separated with commas, how can I tell the query

to return each entry?  :confused:

 

At the moment I do this like so:

SELECT * FROM $table WHERE `country` = '".$country."' AND `active` = 'yes'

 

Please assist

 

Thanks!

Link to comment
Share on other sites

That is a poor table design, you should not have multiple values stored in a single field as this makes it very difficult to do anything with a specific entry from that field. The standard way around this would be to have extra tables. It's not entirely clear from your post what the exact relationship is which makes it difficult to give you an exact design. For this reason I'll make up an example. Let's say you have a table (we'll call it `places`) that stores information on game parks and an example row in your table has a field called `parks` which contains "park1,park2,park3". What you would do is create an extra table called something like `place_parks` which would contain a field for `place_id` and a field for `park` and probably a unique id `park_id`. This way we can select all parks in a place using "SELECT * FROM place_parks WHERE place_id=1" or we can select individual parks using "SELECT * FROM place_parks WHERE park_id=2".

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.