4 messages in com.mysql.lists.javaRe: insert's| From | Sent On | Attachments |
|---|---|---|
| Arun Jamwal | 02 Feb 2000 17:03 | |
| Jeremy B. Friedman | 02 Feb 2000 18:33 | |
| LEBLANC, CLAUDE | 03 Feb 2000 16:24 | |
| Tilmann Singer | 03 Feb 2000 16:31 |
| Subject: | Re: insert's![]() |
|---|---|
| From: | Tilmann Singer (ra...@rosa.com) |
| Date: | 02/03/2000 04:31:20 PM |
| List: | com.mysql.lists.java |
You can also use SET:
INSERT INTO myTable SET field1='value1', field2='value2'
etc. This is nicer if you have to dynamically build SQL Strings
... and you dont have to escape the quotes when you use single quotes as string delimiters in the constructed sql-string.
You could also consider writing a prepared Statement
til
"LEBLANC, CLAUDE" schrieb:
You forgot the field list ! and I don't use quotes for numeric values :
insert into myTABLE (myfield1, myfield2, myfieldA, myfieldB) values ("string1","string2", 1, 2)
note : not all fields have to be specified:
insert into myTABLE (myfield1) values ("string1")
trick : first try the statement right in mySQL to find the syntax that works then copy the same statement in your program.
Claude
"Jeremy B. Friedman" wrote:
I am trying to insert some values into a mysql table that are inputted from the previous servlet page. When I try and insert just text, it works fine, but how do I input variables into the table?
This works:
Stmt.executeUpdate("insert into TABLE
values(\"field1\",\"field2\",\"NULL\",\"20000202\")");
This doesn't:
Stmt.executeUpdate("insert into TABLE values(\" + ptitle + \",\" + particle +
\",\"NULL\",\"20000202\")");
What is the proper syntax for inputting variables into a table? Thanks in advance.
-------------------------------------------------------------------- Jeremy Friedman Computer Science Major jere...@udel.edu Yearbook Webmaster http://copland.udel.edu/~jeremyf http://www.yearbook.udel.edu
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail java...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java...@lists.mysql.com instead.
--
------------------------------------------------------------------- Claude Leblanc Ingénierie du logiciel Bell Canada 1050 Beaver Hall, 2e étage tel: (514) 786-6438 Montréal, Quebec fax: (514) 870-2431 Canada H2Z 1S4 email: clau...@bell.ca
-------------------------------------------------------------------
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail java...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java...@lists.mysql.com instead.




