NutzCN Logo
问答 nutz dao查询被转义
发布于 2164天前 作者 xiaoqiu1235 1782 次浏览 复制 上一个帖子 下一个帖子
标签:

我有一个查询行号的sql

SELECT * from (Select id,(@rowNum:=@rowNum+1) as rowNo From spread_source, (Select (@rowNum :=0) ) b order by id asc) as a

但是执行的时候被转义成了

SELECT * from (Select id,(?:=?+1) as rowNo From spread_source, (Select (? :=0) ) b order by id asc) as a

请问这该怎么处理呢

11 回复

或者调用sql.changePlaceHolder

还是不行
:=后面的没了

SELECT * FROM (Select id,(@@rowNum  WHERE  mod(a.rowNo, 100) = 0

变这样了

sql.changePlaceHolder 吧

sql类没有这个方法啊

 Sql sql = Sqls.create("SELECT * from (Select id,(@rowNum:=@rowNum+1) as rowNo From spread_source, (Select (@rowNum :=0) ) b order by id asc) as a " +
                "where mod(a.rowNo, 100) = 0 AND (a.source = '0014' OR a.source = '999999' OR a.source = '888888') ORDER BY a.rowNo DESC LIMIT 1");
        sql.setCallback(Sqls.callback.records());
        dao.execute(sql);
        List<Record> list = sql.getList(Record.class);
Sql sql = Sqls.create("SELECT * from (Select id,(@@rowNum:=@@rowNum+1) as rowNo From spread_source, (Select (@@rowNum :=0) ) b order by id asc) as a " +
                "where mod(a.rowNo, 100) = 0 AND (a.source = '0014' OR a.source = '999999' OR a.source = '888888') ORDER BY a.rowNo DESC LIMIT 1");

然后贴日志看看

可以了,蟹蟹

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