anolan13 Posted August 5, 2008 Share Posted August 5, 2008 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? Quote Link to comment Share on other sites More sharing options...
revraz Posted August 5, 2008 Share Posted August 5, 2008 Why wouldn't it? It's just data. Quote Link to comment Share on other sites More sharing options...
trq Posted August 5, 2008 Share Posted August 5, 2008 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. Quote Link to comment 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.