开发者

MySQL Selecting where datetime column =

开发者 https://www.devze.com 2023-02-21 18:13 出处:网络
Hi I am trying to get the following sql to work in mysql but it always return an empty result set - however there are definitely entr开发者_开发知识库ies that match the criteria.

Hi I am trying to get the following sql to work in mysql but it always return an empty result set - however there are definitely entr开发者_开发知识库ies that match the criteria. I'm new to mySQl so would appreciate if someone could point out where I am going wrong.

SELECT * FROM  `ch_results` 
WHERE  'readingDateTime' =  '2011-03-29 20:00:00'


Remove the quotes around the field name:

SELECT  *
FROM    `ch_results` 
WHERE   readingDateTime =  '2011-03-29 20:00:00'

Your current query compares string 'readingDateTime' to another string, '2011-03-29 20:00:00', which comparison of course never holds true.


Drop the quotes on the 'readingDateTime'. This is comparing strings to each other.

WHERE  readingDateTime =  '2011-03-29 20:00:00'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号