亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 我想更新排序在100以后的記錄,用sql怎么寫(xiě)? [打印本頁(yè)]

作者: cxytz01    時(shí)間: 2014-04-08 19:11
標(biāo)題: 我想更新排序在100以后的記錄,用sql怎么寫(xiě)?
本帖最后由 cxytz01 于 2014-04-08 19:16 編輯

我想更新排序在100以后的,且滿(mǎn)足where條件的記錄,用sql怎么寫(xiě)? mysql。


我想這么寫(xiě),不過(guò)mysql版本不支持。
update ring_category_details set hotOrNew = 0
  where ctId not in
                       (select ctId from ring_category_details where ctId = 4 order by updatetime desc, weight desc limit 10)
      and hotOrNew = 1;

[Err] 1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'


假如可以這么寫(xiě),感覺(jué)性能是問(wèn)題。



作者: cxytz01    時(shí)間: 2014-04-08 20:12
update ring_category_details set hotOrNew = 0 where id not in (select id from (select id from ring_category_details where ctId = 4 order by updatetime desc, weight desc limit 10) t ) and hotOrNew = 1;
作者: action08    時(shí)間: 2014-04-09 15:51
用存儲(chǔ)過(guò)程來(lái)做吧

思路:1查找排序100號(hào)的ordey_index_key變量
2用update語(yǔ)句where 滿(mǎn)足ordey_index_key條件
作者: action08    時(shí)間: 2014-04-09 15:52
缺點(diǎn),一個(gè)where語(yǔ)句需要執(zhí)行兩次




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2