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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -