Well, I would like to do this:
SELECT IF(1<2, (UPDATE `table` SET `column` = 'iam an update' WHERE `id` LIKE '12345'), 0)
but as I see it doesn't work... lame!
So, I read this post Update MySQL with if condition and this one too MySQL: update a field only if condition is met. And if I understand correctly, I can only put IF() inside the UPDATE, and so to do this:
UPDATE `table` SET `column` = IF(1<2, 'iam an update', 'iam not an update')
WHERE `id` LIKE '12345'
But this is not what I want. What I want is not to use the UPDATE at all if I don't need that. I don't know, but it seems important for me not to run "dump" queries. Why would I need this:
UPDATE `table` SET `column` = 'iam not an update' WHERE `id` LIKE '12345'
if it actually does nothing, I mean actual changes in DB? I already have 'iam not an update' value there, I do not want to reset it! But okay, maybe I don't understand how MySql works, and it so smart that doesn't reset sh..t if values are the same, somehow I doubt that.
My question is simple, is there a way to? Really? In 202.. almost 2022 there's no way to avoid unnecessary queries to DB? Sorry, if I'm kinda emotional.
P.S. And yes, maybe the title must be: Can I use UPDATE inside IF() function?