gpt4 book ai didi

php - SQLite 选择最近 24 小时的记录

转载 作者:行者123 更新时间:2023-12-03 18:33:06 25 4
gpt4 key购买 nike

我将这种数据结构存储在 SQLite 数据库中:

stored datas

我试图在 php 代码中获取过去 24 小时的记录。

我使用在类似问题中找到的以下查询:

SELECT temp FROM Sysstat 
WHERE when >= date('now', '-1 days') AND when < date('now')

但它似乎不起作用并给出错误:

Warning: SQLite3::prepare(): Unable to prepare statement: 1, near "when": syntax error in..

谁能给我一些建议?

最佳答案

"[] 或反引号引用 when:

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.

  1. WHEN

关于php - SQLite 选择最近 24 小时的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47004688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com