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

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -