MySQL, incrementing a row count by ascending dates (simple?) -


i work in access cannot figure logic within it. i'm branching mysql in hopes can this.

have table visits customerid, visitdate


customerid        visitdate   1001            7/6/2015       2315            9/1/2015   2315            12/30/2014   9851            5/5/2013   9851            1/7/2014   9851            3/21/2014  

i'd add column called 'visit number' can label in ascending order each customer's visitdate first, second, etc...

it like:

customerid        visitdate      visitnumber   1001            7/6/2015            1   2315            9/1/2015            1   2315            12/30/2014          2   9851            5/5/2013            1   9851            1/7/2014            2   9851            3/21/2014           3  

it's incrementation based on ascending dates, grouped customerid.

would appreciate tips on this. thanks.

ok. have query use update date whenever visits.

you want cause additional action @ point because equates increment of visits.

if i'm not incorrect, simple bundle of:

your update sql; update mytable  set visitnumber = visitnumber + 1  customerid = (the id of user updating); 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

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

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -