View Full Version : UPDATE depending on value already stored

10-07-2011, 10:48 AM
I'm new to MYSQL and still learning so please bear with me..

I have made a message inbox using PHP and MYSQL. When a message is read it is marked as read. This is stored as a boolean type in the db, 0=unread 1=read I would like to offer the option for the user to mark messages as read/unread.

This would involve a simple check for the current value, and then changing it to the other. I could do this in several queries but I think this is achievable using sub-queries, but how I don't know! :p

Here's the starting point for what I have if its anyhelp, the message_id for the messages to be affected are drawn from an array if your wondering.

"UPDATE SET read=( ) FROM messages WHERE message_id IN ('$ids')"