[英]SQL statement not working - "Operand type clash: date is incompatible with int'
I have a table which i am trying to return the Time and Productno columns for a specific date. 我有一个表,我试图返回特定日期的Time和Productno列。 When i try the following SQL command it returns the error: "Operand type clash: date is incompatible with int'. I have research on forums and this is the way most people have been achieving a similar thing which is getting me puzzled. The data types for the following fields are as follows: Date: date. Time: time(7). Productno: int.
当我尝试以下SQL命令时,它返回错误:“操作数类型冲突:日期与int不兼容。我在论坛上进行研究,这是大多数人实现类似事情的方式让我感到困惑。数据以下字段的类型如下:日期:日期。时间:时间(7).Croductno:int。
SELECT Date, Time, Productno
FROM Products
WHERE (Date = 07 / 09 / 2008)
Please could i be advised where i am going wrong? 我可以被告知我哪里出错了吗?
Thanks. 谢谢。
Your date format is incorrect, it needs to be in quotes and rearranged slightly. 您的日期格式不正确,需要在引号中并稍微重新排列。
WHERE (Date = 'Year-Month-day')
or rather 更确切地说
WHERE (Date = '2008-09-07')
(Date = 07 / 09 / 2008)
(日期= 07/09/2008)
Here you dividing (int)7 by (int)9 and then by (int)2008. 在这里你将(int)7除以(int)9然后除以(int)2008。 So
07 / 09 / 2008
is an integer result of some calculations. 所以
07 / 09 / 2008
是一些计算的整数结果。 In order to pass the date instead, you should put it into quotes. 为了通过日期,你应该把它放在引号中。
Use this 用这个
SELECT Date, Time, Production
FROM Products
WHERE Date="2008-09-07"
Date must be in yyyy-mm-dd
format 日期必须采用
yyyy-mm-dd
格式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.