How to insert multiple selection from JSP to MySQL
Rebecca Green
Greenhorn
Joined: Dec 25, 2009
Posts: 16
posted
0
Hi,
I want to know whether there is any mysql query to insert mulitple values taken from a jsp page... (Languages known : English, Spanish) into a single column. I mean, how do i insert both these values into the Language column in the database ?
Best not write SQL statements in a JSP. A JSP is a view, nothing more.
Can you give the exact query ?
How can I give you one when I know nothing of the table details. It should be a trivial insert / update. I am sure you can figure it out
Costi Ciudatu
Ranch Hand
Joined: Oct 24, 2006
Posts: 74
posted
0
Rebecca Green wrote:...how do i insert both these values into the Language column in the database ?
You do not insert two values in a single column. You need to end up with only one value that contains all those languages: for instance, the string "English, Spanish". Or you could try to see if normalization would help you here (keep the languages in a different table that has a many-to-many relationship with the other table).
Rebecca Green
Greenhorn
Joined: Dec 25, 2009
Posts: 16
posted
0
I found the solution... rather simple one ;)
I just retrieved the multiple select values into a string array using getParameterValues and used another string array to store all these values (comma seperated). I then inserted this string into the database.