I have a forum table which I need to perform the following update
1) I have an original message which I need to change its online status into DISABLE 'D' in my "status" field as follow single command:
UPDATE forum SET status = 'D' where message_id = 1 and parent_id is NULL;
*the parent_id field is NULL because it is a parent thread...
However, it has some child threads to this message...therefore I must force the all the child thread to change the status into 'D' also. So I did a second sql query as follow:
UPDATE forum SET status = 'D' where parent_id = 1;
*parent_id = 1 means it points to the parent message_id = 1
My question is
DOES anyone know a good sql query that will combine these two queries into ONE single query?
thanks
update same table with more than one record
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Maybe:
Mac
Code: Select all
UPDATE forum SET status = 'D' WHERE (message_id = 1 AND parent_id IS NULL) OR parent_id = 1;