SQL keyword BETWEEN numbers is not catching equal?
I have this simple query:
SELECT High, Low FROM prices
WHERE Stock = 'XXX' and Date = '2010-02-05' and Low <= 14.88 AND High >= 14.88
Now for 2010-02-05 Low=14.88 and High开发者_如何学Python=15.88
How come the query return empty? It's running on MySQL 5.0.41
Thanks!
I would check each criteria carefully,
First I would remove all except Stock, then if that returned data, I would include Date, after running that ensuring that data was returned I would include Low (repeat process) and finally High.
When the query stops returning data you should look into why it's stopped. Perhaps it's the date portion. IE if the date on Table Prices is '2010-02-05 12:35:17' it won't match '2010-02-05'
Maybe Stock isn't set to 'XXX'
Please test these and post more information if the issue persists.
Does the select return the row if you remove the high and low checks? The format of your Date clause has me concerned that you're just not matching that row at all. (Just a stab at it, really.)
Either number rounding as in 14.881 or date with a timestammp as Nathan Koop states.
精彩评论