How CONVERT() Works in MySQL

In MySQL, CONVERT() is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.

We provide the value as an argument when we call the function, as well as the type that we want it converted to.

The CONVERT() function is similar to the CAST() function, which also converts between data types.

Continue reading

Fix Error “1064 (42000): You have an error in your SQL syntax…” When Trying to Convert to an Integer in MySQL

If you’re getting error number 1064 that reads something like “1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘INTEGER )’ at line 1“, it could be that you’re using the wrong term for the integer.

MySQL doesn’t let us use just the INTEGER keyword when converting to an integer. We need to use either SIGNED or UNSIGNED, optionally followed by INTEGER or INT. When we do this, it produces a signed or unsigned BIGINT value.

Continue reading