I am trying to get the first and last record from a month. In phpmyadmin I ge the correct result. In python I don't. In fact python returns the same row for both of these queries. First number is the table primary key for the rows.
SELECT *
FROM mcs
WHERE time_stamp < DATE_ADD( DATE_ADD( LAST_DAY( NOW( ) ) ,
INTERVAL 25 HOUR ) ,
INTERVAL -2 MONTH)
AND wot_id = 1010965979
LIMIT 1
838831, '1010965979', datetime.datetime(2015, 3, 6, 22, 0), Decimal('444.88'), Decimal('0.00')
SELECT *
FROM mcs
WHERE time_stamp < DATE_ADD( DATE_ADD( LAST_DAY( NOW( ) ) ,
INTERVAL 24 HOUR ) ,
INTERVAL -1 MONTH)
AND wot_id = 1010965979
LIMIT 1
838831, '1010965979', datetime.datetime(2015, 3, 6, 22, 0), Decimal('444.88'), Decimal('0.00')
phpmyadmin shows this row for the first query,
839037 1010965979 2015-04-01 00:00:00 437.36 0.00
and this for the second:
953868 1010965979 2015-04-30 23:00:00 479.67 0.00
using MySQLdb and python 3
What is wrong? is this a bug in MySQLdb? I would not think so as it just passing a SQL string to mysql
LIMIT
withoutORDER BY
does not guarantee consistent results. – ypercube May 9 at 6:1424 HOUR
, not 25 ! – ypercube May 9 at 6:24