This post is part of the series on MySQL Snippets.
The following MySQL snippet shows an example UPDATE
statement for MySQL; I’m posting this as I have trouble remembering that the order of the MySQL statement is different to that of Microsoft SQL Server; in MySQL the SET
clause comes after the JOIN
clause, whereas in Microsoft SQL Server, with which I am more experienced, the order is reversed.
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
UPDATE
bct_custom_fieldnotes AS cfn
INNER JOIN
bct_custom_fields AS cf
ON
cf.TableName = cfn.TargetTableName
SET
cfn.TargetDBTableName = cf.DBTableName
WHERE
cf.TableName <> cfn.TargetTableName;
Click to show/hide the MySQL Snippets Series Index
MySQL Snippets |
---|
Update Statement |