mysql 查询一个时间段之间的记录
我想查询一个时间段之间的记录,比如说是2013-02-12到'2013-03-10之间的,时间段内的时间不确定,是用户选择的,请问怎么写sql语句。这是我写的sql语句,...
我想查询一个时间段之间的记录,比如说是2013-02-12到'2013-03-10之间的,时间段内的时间不确定,是用户选择的,请问怎么写sql语句。这是我写的sql语句,可是不对,请问哪里不对呢?
select * from (select *,'caozuo'as caozuo from mj_searched ) a where ( publishedtime >= '2013-02-12' AND publishedtime <= '2013-03-10') 展开
select * from (select *,'caozuo'as caozuo from mj_searched ) a where ( publishedtime >= '2013-02-12' AND publishedtime <= '2013-03-10') 展开
1个回答
展开全部
1. sql 中字段不要加‘ ’ =>滚咐前衡select *, caozuo as caozuo from mj_searched (多此一举吗? 有*了 还艺大悔纯单独查caozuo)
2. select *, caozuo as caozuo from mj_searched where publishedtime >= '2013-02-12' AND publishedtime <= '2013-03-10';
2. select *, caozuo as caozuo from mj_searched where publishedtime >= '2013-02-12' AND publishedtime <= '2013-03-10';
追问
这是我们系统自动生成的,必须得加上。你这么写也对,刚才我测出来了,我那写么正确,因为我少复制了半个括号所以出现错误了。
你这么写是直接写sql语句的。谢谢。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询