4 messages in com.mysql.lists.javaRe: insert's
FromSent OnAttachments
Arun Jamwal02 Feb 2000 17:03 
Jeremy B. Friedman02 Feb 2000 18:33 
LEBLANC, CLAUDE03 Feb 2000 16:24 
Tilmann Singer03 Feb 2000 16:31 
Subject:Re: insert's
From:LEBLANC, CLAUDE (clau@bell.ca)
Date:02/03/2000 04:24:40 PM
List:com.mysql.lists.java

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

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.

-------------------------------------------------------------------