How to Swap the Values of Two Columns in MySQL With One Query

Swapping two columns looks like a one-liner, but MySQL evaluates assignments left to right, so the obvious query copies one column over the other. Here is a version that really swaps.

Swapping two columns looks like a one-liner, but MySQL evaluates assignments left to right, so the obvious query copies one column over the other. Here is a version that really swaps.

Google Product Search became Google Merchant Center, but the XML feed idea is the same. This builds a valid feed from MySQL with PHP, streaming rows so large catalogs work.

The old mysql_* export script no longer runs on PHP 7 or 8. Here is a PDO version that streams large tables safely, plus a one-line command-line alternative.