本文介绍了如何从仅使用日期的DATETIME列中选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的表上有一个DATETIME列,用于存储创建记录的时间。我只想选择在特定日期创建的记录。如果我尝试:

  SELECT * 
从myTable
WHERE postedOn ='2012-06-06'

即使表中有许多行,也不返回任何行, postedOn 设为
2012-06-06 21:42:02 2012-06-06 07


$ b:解决方案

使用标量:

  SELECT * 
FROM myTable
WHERE date(postedOn) ='2012-06-06'


I have a DATETIME column on my table which stores when a record was created. I want to select only the records created on a particular date. If I try:

SELECT * 
FROM myTable
WHERE postedOn =  '2012-06-06'

It returns no rows even though there are many rows in the table with the postedOn set as 2012-06-06 21:42:02, 2012-06-06 07:55:17 , and so forth.

Any ideas?

解决方案

Use the DATE scalar:

SELECT * 
FROM myTable
WHERE date(postedOn) =  '2012-06-06'

这篇关于如何从仅使用日期的DATETIME列中选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 13:57