mysql - How to count how many days passed from the beginning -
totally edit question. because guess first try unclear. have table 3 columns. need add new column , fill time passed begining
|| *station_id* || *counter* || *stop* || *time begining* || || 22500 || 0 || 16:15:00 || || || 22710 || 1 || 17:24:00 || || || 22790 || 2 || 18:10:00 || || || 22670 || 3 || 19:43:00 || || || 22800 || 4 || 21:42:00 || || || 22920 || 5 || 22:47:00 || || || 24050 || 6 || 00:53:00 || || || 24010 || 7 || 02:13:00 || || || 24280 || 8 || 02:30:00 || || || 24270 || 9 || 02:57:00 || || || 24250 || 10 || 03:45:00 || || || 24249 || 11 || 06:45:00 || || || 25270 || 12 || 08:06:00 || || || 1190 || 13 || 09:23:00 || || || 25230 || 14 || 10:43:00 || || || 25201 || 15 || 11:23:00 || || || 25215 || 16 || 11:54:00 || || || 24605 || 17 || 13:05:00 || || || 24577 || 18 || 13:44:00 || || || 24580 || 19 || 14:23:00 || || || 24583 || 20 || 15:09:00 || || || 24585 || 21 || 15:40:00 || || || 24610 || 22 || 16:40:00 || || || 24850 || 23 || 17:47:00 || || || 24840 || 24 || 18:12:00 || || || 24500 || 25 || 21:32:00 || || || 24760 || 26 || 00:52:00 || || || 24100 || 27 || 06:23:00 || || || 24791 || 28 || 08:55:00 || || || 24938 || 29 || 10:05:00 || || || 24943 || 30 || 10:34:00 || || || 21602 || 31 || 11:52:00 || || || 21609 || 32 || 14:58:00 || || || 21800 || 33 || 16:32:00 || || || 21630 || 34 || 17:13:00 || || || 21646 || 35 || 18:02:00 || || || 21640 || 36 || 18:55:00 || || || 21650 || 37 || 19:15:00 || || || 21670 || 38 || 20:38:00 || || || 21654 || 39 || 21:13:00 || || || 21680 || 40 || 21:35:00 || || || 21658 || 41 || 22:39:00 || || || 21600 || 42 || 01:11:00 || || || 21760 || 43 || 03:09:00 || || || 27580 || 44 || 04:43:00 || || || 27453 || 45 || 05:14:00 || || || 27570 || 46 || 05:34:00 || || || 27560 || 47 || 06:22:00 || || || 27438 || 48 || 06:52:00 || || || 27550 || 49 || 07:53:00 || || || 27530 || 50 || 09:04:00 || || || 27200 || 51 || 11:14:00 || || || 27240 || 52 || 14:08:00 || ||
how update it, , put last question how many minutes passed station counter=0.
my wrong try looks like:
select station_id,counter, stop_ends, if(timediff(stop_ends, @diff := (select (stop_ends) route ri ri.train_id=ro.train_id , counter=0)) >= 0, timediff(stop_ends, @diff), sec_to_time( time_to_sec(timediff('23:59:59', @diff)) + 1 + time_to_sec(timediff(stop_ends, '00:00:00'))) ) travel route ro train_id = 1130 order counter
it estimate time, within first day.
from understand have 1 entry per day, , want return day each entry relative other entry.
sql data isn't ordered that. doesn't order data based on when it's added system. unless have column incremented id or date added or something, there's not can do.
if have kind of incrementing id column or date added column, you're simple comparison away answer. show schema , here can help.
if you're still designing system , need functionality, add column. if you're working on existing system , data set, you're kind of sol.