mySQL Concatenation of Strings

Error Code: 1292. Truncated incorrect DOUBLE value

This was triggered by the random-ish appearance of this error code while trying what I thought should be a simple concatenation of two strings.

The process within mySQL Concatenation of strings is not:

SET @wholestring = 'this string' + 'this other string';

Which does give the “Error Code: 1292. Truncated incorrect DOUBLE value” but….

Use

SET @wholestring = CONCAT('this string', 'this other string');

And joy will be returned to your coding efforts.

That said, note that this CONCAT example is with fixed strings.

Using variables or constants in the CONCAT entries may trip you up if any of them are equal to NULL.

SET @wholestring = CONCAT(@string1, @string2, @resultofSQLSELECT, @someothervalue);

Will provide a NULL result in @wholestring, if ANY one (or more) of the values inside the CONCAT() equate to NULL.

Reference: https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat

Leave a Comment