MySQL concatenating strings
Posted: Mon Oct 20, 2008 10:49 am
Hi everyone
I'm trying to take 3 MySQL values, and join them together into 1 string.
I could do this in PHP, but thought I may as well take advantage of the MySQL CONCAT() function. PHP's got enough to do without doing this through 20,000 records at a time
So here's a part of my query:
However it's not working as I'd like. According to the MySQL manual this will only work if all the strings are NOT NULL. I'd like to be able to just concatenate these fields, regardless of any NULL values.
Is there any way in MySQL to achieve this?
Thanks, B
I'm trying to take 3 MySQL values, and join them together into 1 string.
I could do this in PHP, but thought I may as well take advantage of the MySQL CONCAT() function. PHP's got enough to do without doing this through 20,000 records at a time
So here's a part of my query:
Code: Select all
SELECT CONCAT(`invoice_prefix`, `invoice_id`, `invoice_suffix`) AS `invoice_no`Is there any way in MySQL to achieve this?
Thanks, B