| Bug #7533 | CONCAT fails if one of the columns is NULL | ||
|---|---|---|---|
| Submitted: | 25 Dec 2004 10:52 | Modified: | 27 Dec 2004 13:34 |
| Reporter: | Anthony Marston | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 4.1.8 | OS: | Windows (Windows XP) |
| Assigned to: | Sergei Golubchik | CPU Architecture: | Any |
[25 Dec 2004 10:52]
Anthony Marston
[27 Dec 2004 12:06]
MySQL Verification Team
I can't repeat it with 4.1.9-debug.
mysql> SELECT student_id, CONCAT(first_name, " ", initials, " ", last_name) AS
-> student_name, year FROM crs_student WHERE (student_id='1') OR (student_id='2')
-> OR (student_id='3');
+------------+-----------------+------+
| student_id | student_name | year |
+------------+-----------------+------+
| 1 | Anthony J Abbot | 1 |
| 2 | NULL | 1 |
| 3 | NULL | 1 |
+------------+-----------------+------+
3 rows in set (0.00 sec)
[27 Dec 2004 12:50]
Anthony Marston
Your example shows that for student_id=2 and student_id=3 the result of the CONCAT statement is NULL even though two of the three named columns are not NULL. +------------+-----------------+------+ | student_id | student_name | year | +------------+-----------------+------+ | 1 | Anthony J Abbot | 1 | | 2 | NULL | 1 | | 3 | NULL | 1 | +------------+-----------------+------+ The output for student_id=2 should be 'Bartholomew Barclay' with a NULL middle initial. Just because one of the columns is NULL should not result in the entire output being NULL.
[27 Dec 2004 13:34]
Sergei Golubchik
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: http://dev.mysql.com/doc/mysql/en/String_functions.html
