NutzCN Logo
问答 拼接sql语句的到的数据
发布于 192天前 作者 qq_68fbea12 116 次浏览 复制 上一个帖子 下一个帖子
标签: ssdb

这个是拼接的sql语句

Cnd c=Cnd.NEW();
		c.where().and("recommend_type","=",type).and("recommend_area","=",area);
		c.and("UNIX_TIMESTAMP(recommend_begintime)","<=","UNIX_TIMESTAMP("+dateUtil.currentDatetime(time)+")").and("UNIX_TIMESTAMP(recommend_endtime)",">=","UNIX_TIMESTAMP("+dateUtil.currentDatetime(time)+")");
		c.asc("recommend_area_order");

得到的sql语句是

SELECT * FROM os_recommend  WHERE recommend_type=0 AND recommend_area=0 AND UNIX_TIMESTAMP(recommend_begintime) <= 'UNIX_TIMESTAMP(2017-04-11 02:39:35)' AND UNIX_TIMESTAMP(recommend_endtime) >= 'UNIX_TIMESTAMP(2017-04-11 02:39:35)' ORDER BY recommend_area_order ASC

但是我想要的sql语句是这种的

SELECT * FROM os_recommend  
WHERE recommend_type=0 AND recommend_area=0 
AND UNIX_TIMESTAMP(recommend_begintime)<= UNIX_TIMESTAMP('2017-04-11 13:29:58') AND UNIX_TIMESTAMP(recommend_endtime)>= UNIX_TIMESTAMP('2017-04-11 13:29:58') 
ORDER BY recommend_area_order ASC

有大神在不,求教求教

3 回复
Cnd c=Cnd.NEW();
		c.where().and("recommend_type","=",type).and("recommend_area","=",area);
		c.and(new Static("UNIX_TIMESTAMP(recommend_begintime) <= UNIX_TIMESTAMP("+dateUtil.currentDatetime(time)+")");
                c.and(new Static("UNIX_TIMESTAMP(recommend_endtime) >= UNIX_TIMESTAMP("+dateUtil.currentDatetime(time)+")");
		c.asc("recommend_area_order");

括号自己补齐一下

谢大神指教,可以了

添加回复
请先登陆
回到顶部