A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
insertion with condition query
Joined: Feb 17, 2013
Feb 17, 2013 01:04:46
I fetched both the values total and reg and i need to know that how to insert a query with checking it with the condition
PreparedStatement st1 = conn.prepareStatement("INSERT INTO gpa(gpa)"+"VALUES(?) where regno = ?"); st1.setDouble(1, total); st1.setString(2,reg[i]); st1.execute();
anyone help thanks in advance
Joined: Oct 14, 2005
Feb 17, 2013 10:22:49
I don't think that's valid SQL. The bad part is, I don't even understand what you want to do with it. Perhaps you could start by explaining that. For example: what's "regno"? A database column? A Java variable?
Joined: Dec 20, 2006
Feb 17, 2013 10:43:20
Paul Clapham wrote:
I don't think that's valid SQL. ...
True. A where statement only works (and only makes sense) on existing rows. And insert is used to add a new row. The two contradict each other.
OCUP UML fundamental and ITIL foundation
I agree. Here's the link:
subject: insertion with condition query
SQL formatting question
Reg : program
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013