The following is a list of date and time functions available in MySQL. Click on each function name to see an explanation of the function, its syntax, and examples.
Continue readingCategory: MySQL
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.
MySQL ROW_COUNT() Explained
In MySQL, ROW_COUNT()
is a built-in function that returns the number of rows updated, inserted, or deleted by the preceding statement.
The value returned by ROW_COUNT()
is often the same as the row count that the mysql
client displays following statement execution, as well as the value from the mysql_affected_rows()
C API function.
FORMAT_BYTES() in MySQL
In MySQL, FORMAT_BYTES()
is a built in function that converts a numeric byte count to a more human-readable format. It returns a string consisting of the value and a units indicator.
We provide the numeric byte count when we call the function.
Continue readingFix 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.
7 Ways to Check your MySQL Version
Here are seven ways to check what version of MySQL you’re running.
Continue readingMySQL VERSION() Explained
In MySQL, VERSION()
is a built-in function that returns the MySQL server version.
The result is a string that uses the utf8mb3
character set. A suffix may also be appended to the version number indicating server build or configuration information.
MySQL Date Format Specifiers (Full List)
The following table contains a full list of format specifiers that can be used in format strings with functions like DATE_FORMAT()
, STR_TO_DATE()
, and FROM_UNIXTIME()
in MySQL.
MySQL SESSION_USER() Explained
In MySQL, SESSION_USER()
is a synonym for the USER()
function. It returns the current MySQL user name and host name, given when connecting to MySQL.
MySQL SYSTEM_USER() Explained
In MySQL, SYSTEM_USER()
is a synonym for the USER()
function. It returns the current MySQL user name and host name, given when connecting to MySQL.