I have this struct of data stored in an SQLite DB:
I'm trying to get the records from the past 24 hours in a php code.
I use the following query that I found at similar questions:
SELECT temp FROM Sysstat
WHERE when >= date('now', '-1 days') AND when < date('now')
But it doesn't seem to work and gives error:
Warning: SQLite3::prepare(): Unable to prepare statement: 1, near "when": syntax error in..
Anyone could give me some advice?
Enquote when
with "
or []
or backticks:
SELECT temp
FROM Sysstat
WHERE "when" >= date('now', '-1 days') AND "when" < date('now');
SQLite Keywords:
The list of keywords is so long that few people can remember them all. For most SQL code, your safest bet is to never use any English language word as the name of a user-defined object.
If you want to use a keyword as a name, you need to quote it.
"keyword" A keyword in double-quotes is an identifier.
- WHEN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With