• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is wrong with this Update Query!!!!

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
This my update query and I don't understand why it gives me error!!!
Please help...
Thanks,
Elahe
PrepStmt=con.prepareStatement("update bug set values (?,?,?,?,?) where bugNumber=?");
PrepStmt.setInt(1,ID);
PrepStmt.setString(2,bdesc);
PrepStmt.setString(3,fixedDate);
PrepStmt.setInt(4,userID);
PrepStmt.setString(5,contact);
PrepStmt.setInt(6,bugNumber);
Error:
--------
You have an error in your SQL syntax near 'values (3,'I can not delete the bug#456','2001-01-01',3,'Rick-408-778-2967') whe' at line 1
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which database are you using? Not all databases support the syntax that you are using. For example, the UPDATE syntax for PostgreSQL is:
UPDATE [ ONLY ] table SET col = expression [, ...]
[ FROM fromlist ]
[ WHERE condition ]

I believe your statement would work with MySQL.
hth,
bear
[ January 23, 2002: Message edited by: Bear Bibeault ]
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I'm usubg MySql but why it gives me syntax error
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,I'm using MySql, but why it gives me error
 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got my answer the query should be like this:
PrepStmt =con.prepareStatement("update bug set ID=?,bdesc=?,fixedDate=?,userID=?,contact=? where bugNumber=?");
Elahe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic