我正在尝试选择记录中的日期(pubMonth + pubYear)已过的作者。我尝试了几种 WHERE 语句的组合,但没有一个能够消除大于 $today 的记录,这是唯一的问题。
这就是我现在所拥有的:
$today = strtotime(date("Y-m-d"));
mysql_select_db($xxxxxxxxxx, $xxxxxxx);
$query_rsfindAuth = "SELECT Author.FirstName, Authors.level2, Authors.pubMonth, Authors.pubYear
FROM Authors
WHERE (UNIX_TIMESTAMP(Author.pubMonth+Author.pubYear)
< $today) AND level2 = 'Nature'
但我已经尝试过每一个,因为我有点在黑暗中拍摄。
WHERE ((Authors.pubMonth+Authors.pubYear ) < " . $today . ") AND level2 = 'Nature'
WHERE (Authors.pubMonth+Authors.pubYear ) < $today AND level2 = 'Nature'
WHERE " . strtotime(pubMonth.pubYear ) . " < $today) AND level2 = 'Nature'
WHERE pubMonth+pubYear) < $today) AND level2 = 'Nature'
WHERE (UNIX_TIMESTAMP(pubMonth+pubYear ) < $today) AND level2 = 'Nature'
WHERE UNIX_TIMESTAMP(pubMonth+pubYear ) < " . $today . ") AND level2 = 'Nature'
一如既往,感谢您的善意帮助。
最佳答案
WHERE UNIX_TIMESTAMP(CONCAT_WS('-', gradYear, gradMonth, '01')) < '$today'
关于mysql - 在 mysql Select 中使用 strtotime 或 Timestamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18796576/