如何使用mysql选择所选日期[2010-11-04]的查询以显示日期

时间:2011-11-21 10:59:13

标签: mysql sql

如何使用MYSQL显示从2010-11-04开始到目前为止的选择查询中的数据

Table : Stu_Details

sl.no name status address created_date
110   soul   1    add      2010-09-01
111   saul   1    add      2010-10-01
112   seth   1    add      2010-10-04//starting date
113   ray    1    add      2010-10-06
114   james  1    add      2010-10-07
115   ram    1    add      2010-10-05
----
115   prem   1    add      2011-11-21//till date

Output

sl.no name status address created_date
112   seth   1    add      2010-10-04
113   ray    1    add      2010-10-06
114   james  1    add      2010-10-07
115   ram    1    add      2010-10-05
----
115   prem   1    add      2011-11-21//till date

4 个答案:

答案 0 :(得分:3)

  SELECT * 
    FROM Stu_Details 
   WHERE created_date >= '2010-10-04'
ORDER BY created_date

答案 1 :(得分:2)

一个简单的where可以解决这个问题吗?

select  *
from    Stu_Details
where   '2010-10-04' <= created_date and created_date < '2011-11-21'

答案 2 :(得分:0)

在哪里

SELECT  *
FROM    Stu_Details
where   created_date >= '2010-10-04' ORDER BY `created_date` ASC

答案 3 :(得分:0)

SELECT * from table where date BETWEEN '2010-10-4' and ('2010-10-4' + INTERVAL 1 DAY)

我是INTERVAL只是字符串版本和计算。只需MySQL即可。