简体   繁体   中英

filter last 24 hour data and collect data from SQL

The following code seems to be not working for me, what went wrong.

$que = "SELECT * FROM people WHERE phone=9876543210 WHERE status=10 AND clickdate > DATE_SUB(CURDATE(), INTERVAL 1 DAY)";

Intention was to collect data of users with the phone number 9876543210 and status=10, but only within last 24 hours from the table "people". "clickdate" is the date column in database.

You have two WHERE in your query. Replace second where with and

SELECT * 
FROM people 
WHERE phone=9876543210 
AND status=10 
AND clickdate > DATE_SUB(CURDATE(), INTERVAL 1 DAY)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM