MySQL offers a bevy of functions for preparing results before returning them. Here we will look at the more common ones. Before we begin, it is worth noting that all MySQL functions are limited by the size of the max_allowed_packet
variable. If the value(s) to be returned exceed the maximum allowed packet size, MySQL will return a NULL value.
For information on fine-tuning server variables such as max_allowed_packet, see: http://dev.mysql.com/doc/refman/5.5/en/server-parameters.html
The CONCAT()
function allows us to concatenate, or join, two or more values. The basic syntax is as follows:
SELECT CONCAT(value1, value2);
The values can be either string or numeric values:
SELECT CONCAT(22, '/', 7); +--------------------+ | CONCAT(22, '/', 7) | +--------------------+ | 22/7 | +--------------------+ SELECT CONCAT('pi = ', 22, '/', 7); +---------------------------------+ | CONCAT('pi = ', 22, '/', 7) | +--------------------------------...