Jump to content

mysql help


anolan13

Recommended Posts

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
https://forums.phpfreaks.com/topic/118205-mysql-help/#findComment-608303
Share on other sites

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.