Jump to content

mysql help


anolan13

Recommended Posts

So I have a MySQL table "Member" with a field called "Interest" I need to put different variables in "Interest" all at the same time

 

For example

 

"Football", "hunting", and "fishing" all need to go in one "Interest" column, where the row is "name"

 

Does MySQL allow this?

 

Is that too confusing?

Link to comment
Share on other sites

A better design would be to have an interest table with two fields, one to store a users id and the other there interest.

 

CREATE TABLE interests (
 id INT PRIMARY KEY AUTO INCREMENT,
 userid INT,
 interest VARCHAR(80)
);

 

Then, to store the interests for user 1....

 

INSERT INTO interests (userid,interest) VALUES (1,'Football');
INSERT INTO interests (userid,interest) VALUES (1,'Hunting');
INSERT INTO interests (userid,interest) VALUES (1,'Fishing');

 

Then to retrieve user 1's interests....

 

SELECT interest FROM interests WHERE userid = 1

 

This could also be broken down further by adding another table to store all the different interest types and simply making the interests table store userid's and interesttype ids.

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.