P
P
prrrrrrr2019-07-31 15:32:37
PHP
prrrrrrr, 2019-07-31 15:32:37

How can I rewrite this expression into an SQL query?

Please tell me how to write this line:

if($view_trip->date_trip.(" ").$view_trip->time_trip >= date("Y-m-d H:i") && $view_trip->view === "yes")
// в date_trip - дата
// в time_trip - время

In this (taking into account ordeb by id desc):
$sql = 'SELECT * FROM trips WHERE view = "yes" ORDER BY id DESC';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Siverius, 2019-07-31
@prrrrrrr

SELECT * FROM trips 
WHERE UNIX_TIMESTAMP(CONCAT(date_trip, " ", time_trip)) >= UNIX_TIMESTAMP() 
    AND view = "yes" 
ORDER BY id DESC

Or like that...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question