我以这种格式 2012-04-16 08:58:55 在我的数据库中保存时间戳。我读取了我的数据库的时间戳,然后我想在另一个查询中使用这个时间戳,并从数据库中请求返回时间戳大于这个时间戳的记录。我正在使用 ">=" 但它不起作用。
我正在尝试这个:
$query="SELECT DISTINCT timestamp,text FROM array WHERE id='$theID' AND timestamp>='$thisTimestamp'";
我以这种格式 2012-04-16 08:58:55 在我的数据库中保存时间戳。我读取了我的数据库的时间戳,然后我想在另一个查询中使用这个时间戳,并从数据库中请求返回时间戳大于这个时间戳的记录。我正在使用 ">=" 但它不起作用。
我正在尝试这个:
$query="SELECT DISTINCT timestamp,text FROM array WHERE id='$theID' AND timestamp>='$thisTimestamp'";
What exactly does "not working" mean? It's not clear whether you want to compare datetime stamps or simply the time porition.
For the former, check this thread Mysql Compare two datetime fields, for the latter, simply use the TIME() function in your query e.g. SELECT * FROM table WHERE TIME(datetime) >= '08:58:55';
Clarify your question if you are in search of something else.
EDIT: Have you not read my first link? That is exactly what you need given the problem you have provided so far. What results are you looking for? Give an example and then give an example of how your query is performing incorrectly. Without this information, no one will be able to give you complete help!