是否可以用一行 更新SQL中的多个字段。
这是一个例子:
"UPDATE badgeownedbadges SET badgeID =(SELECT badgeID FROM badges WHERE badgename=%s) SET scoutID = (SELECT scoutID FROM scoutinfo WHERE firstname=%s AND secondname=%s)"
将%s作为适用变量
答案 0 :(得分:1)
是的,就像使用select
查询一样,只需使用逗号分隔字段即可:
UPDATE badgeownedbadges
SET
badgeID = (SELECT badgeID FROM badges WHERE badgename=%s),
scoutID = (SELECT scoutID FROM scoutinfo WHERE firstname=%s AND secondname=%s)