Select 来自 table 日期晚于今天
Select from table where the date is later then today
所以我正忙于计划系统,并且由于我的客户在科技行业工作,我想根据日期制作一个 table 列出 5 部即将上映的作品。
最初的方法有点愚蠢:
$date = date('d-m-Y');
SELECT id, name, date, location FROM productions WHERE date = > :date
如前所述,相当愚蠢,然后在Whosebug上,我找到了一段对我来说有意义的代码:
SELECT id, name, date, location FROM productions WHERE date >= CURRENT_DATE LIMIT 5 ORDER BY date
但是当我尝试这样做时,出现了以下错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'ORDER BY date' at line 1' in C:\xampp2\htdocs\public\planning.tpl:341 Stack trace: #0 C:\xampp2\htdocs\public\planning.tpl(341): PDO->prepare('SELECT id, name...') #1 C:\xampp2\htdocs\application\classes\class.template.php(61): include('C:\xampp2\htdoc...') #2 C:\xampp2\htdocs\application\classes\class.template.php(70): Template->getPage('planning') #3 C:\xampp2\htdocs\index.php(8): Template->render('planning') #4 {main} thrown in C:\xampp2\htdocs\public\planning.tpl on line 341
那我该怎么做呢?问了好几个人都不知道..
那么我如何 select 来自日期晚于今天的 table 的值?
谢谢
ORDER BY
在 LIMIT
之前
在此处检查整个语法:MySQL Select Syntax
SELECT id, name, `date`, location FROM productions
WHERE date(`date`) >= CURRENT_DATE ORDER BY date(`date`) LIMIT 5
所以我正忙于计划系统,并且由于我的客户在科技行业工作,我想根据日期制作一个 table 列出 5 部即将上映的作品。
最初的方法有点愚蠢:
$date = date('d-m-Y');
SELECT id, name, date, location FROM productions WHERE date = > :date
如前所述,相当愚蠢,然后在Whosebug上,我找到了一段对我来说有意义的代码:
SELECT id, name, date, location FROM productions WHERE date >= CURRENT_DATE LIMIT 5 ORDER BY date
但是当我尝试这样做时,出现了以下错误:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'ORDER BY date' at line 1' in C:\xampp2\htdocs\public\planning.tpl:341 Stack trace: #0 C:\xampp2\htdocs\public\planning.tpl(341): PDO->prepare('SELECT id, name...') #1 C:\xampp2\htdocs\application\classes\class.template.php(61): include('C:\xampp2\htdoc...') #2 C:\xampp2\htdocs\application\classes\class.template.php(70): Template->getPage('planning') #3 C:\xampp2\htdocs\index.php(8): Template->render('planning') #4 {main} thrown in C:\xampp2\htdocs\public\planning.tpl on line 341
那我该怎么做呢?问了好几个人都不知道..
那么我如何 select 来自日期晚于今天的 table 的值?
谢谢
ORDER BY
在 LIMIT
在此处检查整个语法:MySQL Select Syntax
SELECT id, name, `date`, location FROM productions
WHERE date(`date`) >= CURRENT_DATE ORDER BY date(`date`) LIMIT 5