简体   繁体   中英

sql query giving inconsistent results

I have an sql database with an orders table with primary key as order_no(int) and order_dispatch_date (timestamp). I have 46 rows that have the date(order_dispatch_date) as '2017-12-09', but when I do the following query, it displays only 45 rows:

select * from orders where date(order_dispatch_date)=('2017-12-09')

So i further investigated and found out that an order_no 1029547 was not getting displayed in the results and thats where my problem was. I also executed this query which gives me the same result, 45 rows except the row with order_no 1029547

 SELECT * FROM `orders` WHERE date(order_dispatch_date)=(SELECT date(order_dispatch_date) from orders WHERE order_no=1029547)

Why is the row with order_no 1029547 not getting displayed in both the results, while it gets displayed in this query:

SELECT * FROM `orders` WHERE date(order_dispatch_date)=date('2017-12-09') and order_no=1029547

Please help me figure out the problem.

我从订单中复制了时间戳记,该订单已显示在order_no 1029547的order_dispatch_date的45行中,当我执行select * from date(order_dispatch_date)='2017-12-09'的订单时,我仍然得到45行

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM