skidmark10 Posted August 1, 2011 Share Posted August 1, 2011 I have an html form with checkbox answers. I want to store the answers in ONE mysql column. When I select for checkbox answers, only the very last one shows up in the column, but I have it enumerated so I don't know why it shows up like that. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/243436-how-do-i-store-multiple-answers-in-one-column/ Share on other sites More sharing options...
gizmola Posted August 1, 2011 Share Posted August 1, 2011 MySQL has a SET column type. http://dev.mysql.com/doc/refman/5.0/en/set.html As far as I'm concerned the SET type violates basic relational database rules of normalization, as it is essentially a repeating group. With that said, if you're dead set on using it, it does provide an answer. I've also seen people store a comma delimited string as a varchar, and even seen people store the data in a varchar or text, in json format. There's a few solutions, but just know in advance that if you want to query for rows that contain specific values with one of these schemes, retrieval is going to be very slow if the database is at all large, because you will have to read every row, parse the values up and determine whether or not the row contains the value(s) you are looking for. A normalized design does not have that problem. Quote Link to comment https://forums.phpfreaks.com/topic/243436-how-do-i-store-multiple-answers-in-one-column/#findComment-1250053 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.