I would like to construct a query that fetches results that occurred between NOW and 15 minutes ago, im getting a mysql error when I try the following , can you help me? thanks
SELECT *
WHERE user_id = '000'
AND date_time < now( )
AND date_time > DATE_SUB( now( ) , INTERVAL 15 MINUTE)
Error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE user_id = '000' AND date_time < now( ) AND date_time > DATE_SUB( now( ) ' at line 2
You need to select FROM a table :)
it lacks FROM TABLENAME
SELECT * FROM TABLENAME
WHERE user_id = '000'
AND date_time < now( )
AND date_time > DATE_SUB( now( ) , INTERVAL 15 MINUTE)
You're missing the FROM
statement
SELECT *
FROM myTable
WHERE user_id = '000'
AND date_time < now( )
AND date_time > DATE_SUB( now( ) , INTERVAL 15 MINUTE)
精彩评论