MySQL Selecting where datetime column =
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'
精彩评论