Insert if no duplicate

is there a way to do that? insert a new row into my database, if there isnt already one with the exact same data. for example if this already exists

id - user_id - ip
3 - 123 - 22.22.2222

and someone tries to submit

user_id: 123
ip: 23.23.23333

it will insert a new row, and not replace the original

INSERT
  INTO daTable
     ( user_id 
     , ip )
VALUES
     ( 123
     , '23.23.23333' )
ON DUPLICATE KEY 
UPDATE ip = VALUES ( ip )

this depends on a unique index on user_id

ON DUPLICATE KEY
UPDATE ip = VALUES ( ip )

what if i didnt want to update the old one, so something like

ON DUPLICATE KEY
DO nothing

and what does KEY refer to? would that check only the id value?

thanks

then you would use INSERT IGNORE

any unique key

check da manual for a full explanation

:slight_smile: