Operator + for String Concatenation - SQL Server to MySQL Migration

In SQL Server, you can use the plus (+) operator to concatenate two or more strings. In MySQL, you can use the CONCAT function.

If one of the operands is NULL, both the plus (+) operator in SQL Server, and the CONCAT function in MySQL return the NULL result. Note that when used for a string and a number, the plus (+) operator performs addition, not string concatenation in SQL Server.

SQL Server:

  -- Concatenate strings
  SELECT 'a' + 'b' + 'c';
  /* abc */  
 
  -- a NULL operand causes the NULL result 
  SELECT 'a' + NULL + 'c';
  /* NULL */  
 
  -- For an integer operand + acts as addition  
  SELECT '1' + 5;
  /* 6 */
 
  SELECT '1a' + 5;
  /* Msg 245, Level 16, State 1, Line 1 */
  /* Conversion failed when converting the varchar value '1a' to data type int. */
 
  -- First + concatenates strings, second + performs addition
  SELECT '-' + '1' + 5;
  /* 4 */
 
  -- String concatenation for numbers as string literals
  SELECT '1' + '5';
  /* 15 */
 

MySQL:

  -- Concatenate strings
  SELECT CONCAT('a', 'b', 'c');
  /* abc */  
 
  -- a NULL operand causes the NULL result 
  SELECT CONCAT('a', NULL, 'c');
  /* NULL */  
 
  -- Concatenate string and integer  
  SELECT CONCAT('1', 5);
  /* 15 */
 
  SELECT CONCAT('1a', 5);
  /* 1a5 */
 
  SELECT CONCAT('-' , '1', 5);
  /* -15 */

For more information, see SQL Server to MySQL Migration.