One row with multiple values?

Discussion in 'MySQL' started by MCJim, May 19, 2008.

  1. #1
    Is it possible in mySQL to have one row with multiple values where individual values could be called?

    For example:

    Name: Bob
    Traits: Fat, funny, friendly

    would it be possible to do this and call a single value for the row that contains multiple values (traits)?

    Thanks in advance; if something is unclear let me know.
     
    MCJim, May 19, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    It would be best to make one table as a primary locator [user_id, name], and then a second table with traits [trait_id, user_id, trait]. You can then select traits from the trait table based on the specific user.

    Using delimitation within a database field is extremely inefficient and goes against what a database is designed to do. But to answer your question, you could parse out the values in the csv field from the script you are using. It wouldn't really be possible to parse them out directly in the database.
     
    jestep, May 19, 2008 IP
  3. MCJim

    MCJim Peon

    Messages:
    163
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    OK, I'll do that. Thanks a lot. I may have some more questions soon.
     
    MCJim, May 19, 2008 IP