我有查询1和查询2来更新同一个表。
如何将此优化为单个查询。
$query1 = "UPDATE user_permissions SET active= 0 WHERE user_id = $my_user_id AND page_id =5";
$query2 = "UPDATE user_permissions SET active= 0 WHERE user_id = $my_user_id AND page_id =6";
答案 0 :(得分:1)
使用IN
像这样:
UPDATE user_permissions SET active= 0 WHERE user_id = $my_user_id AND page_id IN (5, 6)