I'm trying to insert a sublevel to a table from form like in the picture but why can't I use where?
String sql = "insert into BE_Tracker(sub_item) values(?) where id=" id " ";
PreparedStatement st = con.prepareStatement(sql);
st.setString(2,addsubItem);
CodePudding user response:
It sounds like you really wanted an UPDATE
here:
String sql = "UPDATE BE_Tracker SET sub_item = ? WHERE id = ?";
PreparedStatement st = con.prepareStatement(sql);
st.setString(1, addsubItem);
st.setString(2, id);
st.executeUpdate();
CodePudding user response:
you cannot use where in insert into query in this way.
You can use it like, something like that insert into MyTable1 select id,name from MyTable2 where id >5
CodePudding user response:
INSERT (...) VALUES (...)
query cannot use with finding option WHERE ... = ...
.
Insert
row on tableBE_Tracker
.- Find rows in table
BE_Tracker
with'WHERE'
option with'SELECT', 'UPDATE'
or'DELETE'
.