Fix “ERROR 3942 (HY000): Each row of a VALUES clause must have at least one column” when using the VALUES Statement in MySQL

If you’re getting an error that reads “ERROR 3942 (HY000): Each row of a VALUES clause must have at least one column” in MySQL, you could have an empty row constructor when using the VALUES statement.

To fix this issue, make sure you’ve got at least one value in each ROW() clause within the VALUES statement.

Continue reading

Fix “ERROR 1136 (21S01): Column count doesn’t match value count at row 2” when using the VALUES Statement in MySQL

If you’re getting an error that reads something like “ERROR 1136 (21S01): Column count doesn’t match value count at row 2” when using the VALUES statement in MySQL, it’s probably because there’s a mismatch in the number of columns specified in the ROW() clauses.

To fix this error, be sure that all ROW() clauses contain exactly the same number of columns.

Continue reading

Fix “ERROR 1250 (42000): Table ‘…’ from one of the SELECTs cannot be used in global ORDER clause” when using UNION in MySQL

If you’re getting an error that reads “ERROR 1250 (42000): Table ‘…’ from one of the SELECTs cannot be used in global ORDER clause” when using the UNION clause in a MySQL query, it’s probably because you’re qualifying a column name with its table name.

This doesn’t work in MySQL.

To fix this issue, either remove the table name or use a column alias.

Continue reading