4 ms·
I'm sorry for being a SQL noob. Can you elaborate on what is wrong with this, and what would be the way to write it without causing the scale of problem describ
by gknoy 7y ago
I'm sorry for being a SQL noob. Can you elaborate on what is wrong with this, and what would be the way to write it without causing the scale of problem described in the OP?
- brianwu02 7y agothe last OR statement "OR 102" will evaluate true. It should be UPDATE permissions SET allow = 1 WHERE user=671156 AND permission=16 AND org=101 OR org=102;
- fazzone 7y agoThe problem is that the condition is parsed as (user=671156 AND permission=16 AND org=101) OR 102 The right way is to use something like org IN (101, 102)
- jimnotgym 7y agoThere are lots of good answers already posted, but if I can make a further suggestion... It is often worth running a SELECT on the WHERE clause you are about to use for your UPDATE. That way you can make sure only a limited amount of data comes back before you launch something catastrophic.