sql - Increment field in MySql if duplicate value -


i have table keeps track of ip addresses 3 fields -- id, ip, total.

if i'm inserting duplicate ip value, i'd increment total field 1.

how should this?

you mean counting total ? add 1 if ip existing ?

    declare @total int = (select count(total) tablename)      if exist (select ip tablename)        begin           set @total = @total + 1        end      insert into... 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

excel - I can't get the attachement of the email PHP -

node.js - Express and Redis - If session exists for this user, don't allow access -