Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert multiple selection from JSP to MySQL

 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

Can anyone tell me the answer?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer depends on your scenario. You can save it as a comma separated String. Not necessarily a JSP related question
 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give the exact query ?
I am using it in a JSP page... so thought I might tel it here...
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic