2014-12-02 69 views
2

我试图拉今天所有的预订,但是我遇到了最后一行的语法错误。SQL语法错误当今天匹配记录

SELECT 
    booking.BookingID, booking.CustID, booking.CostID, booking.DateOut, 
    customer.Fname, customer.Sname, costume.Description, costume.Size 
FROM 
    booking 
INNER JOIN 
    customer ON booking.CustID = customer.CustID 
INNER JOIN 
    costume ON booking.CostID = costume.CostID 
WHERE 
    booking.DateOut = Date(); 

任何帮助表示赞赏!

错误消息: #1064 - 您的SQL语法错误;检查对应于你的MySQL服务器版本正确的语法使用近“) LIMIT 0,25”在第7行

+0

** **数据库系统和哪个版本? ** SQL **只是结构化查询语言(Structured Query Language) - 许多数据库系统使用的语言 - SQL是** NOT **数据库产品......类似这样的东西通常是供应商特定的 - 所以我们真的需要知道什么您正在使用的数据库系统....(请相应地更新标签) – 2014-12-02 10:57:53

+0

请添加** exact **错误消息。 – 2014-12-02 10:58:11

+1

我猜'MySql'是因为['Date'函数](http://www.w3schools.com/sql/func_date.asp)。 – 2014-12-02 11:00:20

回答

3
SELECT 
    booking.BookingID, booking.CustID, booking.CostID, booking.DateOut, 
    customer.Fname, customer.Sname, costume.Description, costume.Size 
FROM 
    booking 
INNER JOIN 
    customer ON booking.CustID = customer.CustID 
INNER JOIN 
    costume ON booking.CostID = costume.CostID 
WHERE 
    booking.DateOut = CURDATE(); 
+1

感谢马特,那工作 – ababusa 2014-12-02 11:12:36

1
SELECT booking.BookingID, 
    booking.CustID, 
    booking.CostID, 
    booking.DateOut, 
    customer.Fname, 
    customer.Sname, 
    costume.Description, 
    costume.Size 
FROM booking 
INNER JOIN customer 
ON (booking.CustID = customer.CustID) 
INNER JOIN costume 
ON (booking.CostID  = costume.CostID) 
WHERE booking.DateOut = new_DATE(sysdate); 
1

日期()函数用于提取日期手册日期或日期时间表达式的一部分。 即Date('12/02/2014 4.33 p.m')会给你'12/02/2014'。 所以你必须提供一个参数给这个函数。

根据您的要求,您应该使用CURDATE()函数。

+1

并感谢你以及解释:) – ababusa 2014-12-02 11:32:20