Form Mysql Join -
my table construction :
select * `mytable` `userid` = 148 order `tabledate` desc; id userid state_id tabledate 96 148 13 2013-01-08 06:11:34 554 148 3 2013-01-03 04:46:08 25 148 2 2013-01-02 04:46:07
i want seconds highest entry of users in table "mytable" (=> order state_id desc limit 1,1) date lastly entry on date "2013-01-08".
i seek form query failed.please help ?
select f1.userid, max(f2.tabledate), f2.state_id mytable f1 bring together mytable f2 on f1.userid = f2.userid f1.state_id = 13 , f2.tabledate < f1.tabledate , f1.tabledate <= '2013-01-08 23:59:59' , f1.tabledate >= '2013-01-08 00:00:00' grouping f1.userid
output
148 2013-01-03 04:46:08 2
expected output
148 2013-01-03 04:46:08 3
if want row had sec highest value of state_id
can this:
select * ( select * yourtable limit 2 ) sub order state_id limit 1;
mysql
No comments:
Post a Comment