I've got 3 columns in a mysql database that I am trying to join. I'm using
CONCAT(), but it's giving me NULL results. This has worked for me before ...
What am I doing wrong?
Here's a straight select:
mysql> select peopleID, firstName, middleInit, lastname
-> from people;
+----------+-----------+------------+------------+
| peopleID | firstName | middleInit | lastname |
+----------+-----------+------------+------------+
| 1 | Joe | NULL | Shockey |
| 3 | John | NULL | Doe |
Here my select with the concat. It's not concatenating the string for some
reason:
mysql> select peopleID, CONCAT(firstName, ' ', middleInit, ' ', lastname) AS
person
-> from people;
+----------+--------+
| peopleID | person |
+----------+--------+
| 1 | NULL |
Can anyone tell me what I'm doing wrong? Should I be using a different
method for joining these srings?
BTW - here's my table structure:
mysql> show columns from people;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| peopleID | int(10) | | PRI | NULL | auto_increment |
| firstName | varchar(50) | YES | | NULL | |
| middleInit | varchar(50) | YES | | NULL | |
| lastName | varchar(50) | YES | | NULL | |
| phone | varchar(50) | YES | | NULL | |
| email | varchar(50) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+