String Concatenation (+) - Sybase ASE to MariaDB Migration

In Sybase ASE you can use the string concatenation operator + to concatenate two or more string values. If any value is NULL the operator treats it as an empty string:

Sybase ASE:

SELECT 'a' + 'b';
-- Result: 'ab'
 
SELECT NULL + 'a' + 'b';
-- Result: 'ab'

In MariaDB you can use CONCAT function to concatenate strings. Note that unlike Sybase ASE if any string is NULL the result of the entire concatenation is NULL:

MariaDB:

SELECT CONCAT('a', 'b');
-- Result: 'ab'
 
SELECT CONCAT(NULL, 'a', 'b');
-- Result: NULL

If you know that a string can accept NULL values you can use IFNULL function to replace NULL before the concatenation with another string:

MariaDB:

-- Some variable that can be NULL
SET @a = NULL;
 
SELECT CONCAT(@a, 'a', 'b');
-- Result: NULL
 
SELECT CONCAT(IFNULL(@a, ''), 'a', 'b');
-- Result: 'ab'

For more information, see Sybase ASE to MariaDB Migration.