gpt4 book ai didi

sql - 我应该为这个查询使用什么数据来返回结果?

转载 作者:行者123 更新时间:2023-11-29 05:43:44 25 4
gpt4 key购买 nike

这是我的 SQL 查询。我的表中有此查询的数据。但是这个查询不返回任何结果。

Select Prod_Batch_ID,tbl_product.product_name, Quantity,DATE_FORMAT(Production_Date, '%W, %D %M %Y') from tbl_production,tbl_product where tbl_production.Product_ID  = tbl_product.Product_ID and (Production_Date between STR_TO_DATE('2010-01-01 00:00:00.000','%m/%d/%Y')and DATE_ADD(STR_TO_DATE('2010-12-12 00:00:00.000','%m/%d/%Y'), INTERVAL 1 DAY))

表中Production_Date列为时间戳类型。使用 str_to_date 转换为日期是这里的问题吗?

最佳答案

问题是您不能查询时间戳列。引用自 SQL Server 联机丛书:

The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that indicate the relative sequence in which data modifications took place in a database. The timestamp data type was originally implemented to support the SQL Server recovery algorithms.

关于sql - 我应该为这个查询使用什么数据来返回结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4481686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com