mysql - MySQLI SELECT with multiple clauses for epoch timestamps selection -


i have epoch timestamps "part_epoch" column, table name "crud_mysqli"

  • i select associated "part_id" value next future timestamps. (avoid research past timestamps)

the following mysqli query should select min (next) value within future : > now.

but not return anything. return expected return if state clauses seperately, combining clauses below returns no result.

would please tell me wrong here :

    // find next event part_id name :     // select lowest (next) part_id value in future (do not select winthin past part_epoch values)     $query = "select     part_id     crud_mysqli     (part_epoch = (select min(part_epoch) crud_mysqli))     , (part_epoch > unix_timestamp(now()))     "; 

where (part_epoch = (select min(part_epoch) crud_mysqli)) 

here take entry lowest timestamp, somthing in past.

and (part_epoch > unix_timestamp(now())) 

and here say, should in future. 2 conditions excluding each other, if have entry timestamp in future.

so need put second condition subquery:

select part_id crud_mysqli part_epoch = (     select min(part_epoch)      crud_mysqli     part_epoch > unix_timestamp(now()) ) 

that means: "take entry lowest timestamp in past"

however.. can following:

select part_id crud_mysqli part_epoch > unix_timestamp(now()) order part_epoch asc limit 1 

the result differ if have 2 entries same timestamp. in case first query return both of them - second query one.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -