java - Insert only if row doesn't exist -


i using preparedstatement prepare sql queries. want insert row in table if , if doesn't exist.

i tried -

insert users (userid) values (?) on duplicate key update userid = ? 

but unnecessarily update userid.

how can insert userid here ?

insert  users          (userid)  select  ?   not exists         (         select  *             users            userid = ?         ) 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -