i am wanting to try and run a query which will update my table ptb_messages and switch the data of two columns around, for instance heres my table:
id | to_user_id | from_user_id |
1 4 5
2 5 6
3 7 9
so what i want to try and do is switch the value of from_user_id over to to_user_id and vice versa.
i was going to use this before i realised that once i copied the value from one table to the other the the original data from the other column would then have been overwritten,
$sql = mysql_query("UPDATE ptb_messages SET ptb_messages.from_user_id=ptb_messages.to_user_id");
what i really need is a swap function,
im not really sure how i might do this but im imagining its something like this:
$sql = mysql_query("UPDATE ptb_messages SET to_user_id=from_user_id, from_user_id=to_user_id");
hope someone can help me please.