NutzCN Logo
问答 sql参数自动加引号问题
发布于 3323天前 作者 lmm1990 3192 次浏览 复制 上一个帖子 下一个帖子
标签: dao

Sql sql = Sqls.create("select * from WebSite where Status != -1 and @whereParam");
sql.setParam("whereParam","id > 0");

System.out.println(sql.toString());
结果:select * from WebSite where Status != -1 and 'Id > 0'

怎么样让它不自动加引号呢?

2 回复

@是参数, $是变量

Sql sql = Sqls.create("select * from WebSite where Status != -1 and $whereParam");
sql.setVal("whereParam","id > 0");

System.out.println(sql.toString());

建议用Cnd,而不是直接拼条件

		Sql sql = Sqls.create("select * from WebSite @cnd and Status != -1");
		sql.setParam("cnd", Cnd.where("id", ">", 0));
		System.out.println(sql);
添加回复
请先登陆
回到顶部