NutzCN Logo
问答 请大神分析一下 我下面条件mau.appid=@keyid 为什么没起作用
发布于 3223天前 作者 qq_722cb381 2156 次浏览 复制 上一个帖子 下一个帖子
标签:

/*find.mobileauth.by.list.serch*/
SELECT * from
(SELECT
ROW_NUMBER() OVER (ORDER BY mau.id) AS NO,
mau.id AS id,
map.name AS mobilename,
mau.no AS nos,
mau.password AS password,
mau.devices AS devices,
mau.firstlogin AS firstlogin,
mau.uselog AS uselog,
mau.description AS descs,
mau.appid AS appid

FROM
mc_magiccard_code mau
LEFT JOIN mc_magiccard map ON map.id = mau.appid
$condition WHERE mau.appid=@keyid and mau.no like @searchKey OR mau.password like @searchKey OR map.name like @searchKey
)t
$condition WHERE t.NO BETWEEN @pageStart AND @pageSize ORDER BY t.NO DESC

9 回复

没起作用是什么意思?

假如 mau.appid=1 查出来的结果 是全部的 而不是appid=1的

把条件写死试试

SELECT * from
(SELECT
ROW_NUMBER() OVER (ORDER BY mau.id) AS NO,
mau.id AS id,
map.name AS mobilename,
mau.no AS nos,
mau.password AS password,
mau.devices AS devices,
mau.firstlogin AS firstlogin,
mau.uselog AS uselog,
mau.description AS descs,
mau.appid AS appid
FROM
mc_magiccard_code mau
LEFT JOIN mc_magiccard map ON map.id = mau.appid
WHERE mau.appid=1 and mau.no like '%%' OR mau.password like '%%' OR map.name like '%%'
)t
ORDER BY t.NO DESC

你看就是写死的 但是现在有一个问题就是 如果mau.appid=1 和mau.no like '%%' OR mau.password like '%%' OR map.name like '%%'并存 筛选出来的条件并没有按照appid=1 也就是说这个条件没有用 如果这两个条件任意去掉一个的话 还好用 我挺郁闷的

我晕,那是你sql写错了

改成这样才能确保mau.appid=1生效

WHERE mau.appid=1 and (mau.no like '%%' OR mau.password like '%%' OR map.name like '%%')

我还想问一下 我接收到的list 为什么是个null

Sql sqlcount =dao.sqls().create("find.mobileauth.by.serch.size");
Entity entity = dao.getEntity(MagicCardCode.class);
sqlcount.params().set("searchKey", searchKey);
sqlcount.params().set("keyid", keyid);
//Sql sqlcount = Sqls.queryRecord("SELECT * FROM t_pet");
dao.execute(sqlcount);
List recs = sqlcount.getList(Record.class);

···
sqlcount.setCallback(Sqls.callback.records());
···

哦 好的 第一次尝试用 感谢!!!

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