UPDATE `items` SET `score`=[value-1],`up_votes`=[value-2],`down_votes`=[value-3] WHERE `ID` = $id
UPDATE `items` SET `score`=[value-1],`up_votes`=[value-2],`down_votes`=[value-3] WHERE `ID` = $id
当ID需要动态时,如何组合这两个查询?
他们都来自表items
。
编辑,得分(可以是+ 10或-10)upvotes(可以是+1或-1)和downvotes(可以是+1或-1)
所以他们也有点动态,对这个误解感到抱歉
答案 0 :(得分:0)
试试这个,$ idlist是逗号分隔的列表,
UPDATE `items` SET `score`=[value-1],`up_votes`=[value-2],`down_votes`=[value-3] WHERE `ID` in ($idlist)
答案 1 :(得分:0)
不同的id与某些条件有关,你可以这样做:
UPDATE `items` SET `score`=[value-1],`up_votes`=[value-2],`down_votes`=[value-3]
WHERE `ID` IN(SELECT ID FROM `items` WHERE SomeCondition)