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

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -