Re: using the same field to be set in the update query and in the where clause
From: Axel Schwenke <axel.schwenke_at_gmx.de>
Date: Fri, 10 Mar 2017 09:06:59 +0100
Message-ID: <o9tmlq$ufo$1_at_dont-email.me>
>
> I'm pretty sure MySQL won't do the work of updating a row where nothing
> actually changes.
Date: Fri, 10 Mar 2017 09:06:59 +0100
Message-ID: <o9tmlq$ufo$1_at_dont-email.me>
[Quoted] On 09.03.2017 17:01, Peter H. Coffin wrote:
> On Wed, 8 Mar 2017 02:24:00 -0800 (PST), kushal bhattacharya wrote:
>> update msg_table set state=? where (msg_id=? and (sock_fd=? and state=?)
>
> I'm pretty sure MySQL won't do the work of updating a row where nothing
> actually changes.
That's nothing you could deduce from that SQL fragment. There are a total of 4 place holders in that query and it's quite possible that #1 and #4 will get different values on execution.
And even if they had the same values, i.e.
update msg_table set state=1 where (msg_id=42 and (sock_fd=4711 and state=1)
[Quoted] that would be a perfectly legal SQL statement. It would have no effect and would always return "0 rows updated". But it's still legal. Received on Fri Mar 10 2017 - 09:06:59 CET