Doing some programming with Java on MySQL.
I have a statement that works like
insert into table1 (col1, col2, col3)
select col1, col2, col3 from table2
where col4 is null
on duplicate key update
col2 = values(col2), col3 = values(col3)
table1 and table2 both have col1 as unique
When I put this into a Statement.executeUpdate(SQL)
, it returns integer 23000ish , however when I simply do select * from table2 where col4 is null
it returns only about 10500ish rows.
My question, according to the java Doc, seems that java.sql.Statement.executeUpdate(String sql)
works as follow
Returns: either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
am I not getting the number of rows updated? Or is it returning something else like the actual number of statments it transformed itself into?
UPDATE::
to expand my question a bit.
The complete statement actually does this
insert into table1 (col1, col2, col3)
select table1.col1, table2.col2, table2.col3
from table1 inner join table2 on table1.col1 = table2.col1
where table1.col4 is null
on duplicate key update
col2 = values(col2), col3 = values(col3)
because of the inner join from table 1, every rows should be an update, no insert should be performed, I am trying to recreate the MERGE function from Oracle 11g.
But my question still remains, is the executeUpdate method returning something else rather than the updated row count?