Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
10-07-2011, 09:48 AM #1
- Join Date
- Jan 2011
- Thanked 0 Times in 0 Posts
UPDATE depending on value already stored
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!
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')"