UPDATE with ucwords function, plus a conditional

I’m using this ucwords function to update the not-proper names in my table, and it’s working perfectly:

UPDATE members SET name = ucwords(name);

I also need to add today’s date to another field in the same table called send_cards. I need to add the date only if the name was updated. This would need to be in the same statement, or maybe there’s another way. But How would I know which records were updated?

I’m trying to do something (wrong) like this:

UPDATE members SET name = ucwords(name), send_cards = IF(ucwords(name), NOW());
UPDATE members 
   SET name = ucwords(name)
     , send_cards = NOW()
 WHERE name <> ucwords(name) 

This returns zero affected rows. Not sure why, because it makes sense logically.

okay, i think i know why

try WHERE BINARY name <> ucwords(name)

:cool:

It works!

Why would we compare byte by byte in this case? Is a character comparison not case sensitive?

that’s correct, it isn’t :slight_smile: