I'm trying to concat 2 columns into a single result
-
SELECT
Label
, (SELECT BFirstName, BLastName FROM CARDINFOPERM WHERE CardID = 1121) AS BAttention
, BCity
FROM CardInfoPerm
WHERE CardID = 1121 -
Perhaps
(SELECT CONCAT(BFirstName, ' ', BLastName) FROM CARDINFOPERM WHERE CardID = 1121) AS BAttention
This works, not sure if it's safe
(SELECT CONCAT(BFirstName, ' ', BLastName)) AS BAttentionSince it's the same table you can just write it like this:
SELECT
Label
, CONCAT(BFirstName, ' ', BLastName) AS BAttention
, BCity
FROM CardInfoPerm
WHERE CardID = 1121jkirkerx wrote:
not sure if it's safe
If you're thinking about null-values:
Quote:
Null values are implicitly converted to an empty string. If all the arguments are null, an empty string of type varchar(1) is returned.
(From https://msdn.microsoft.com/en-us/library/hh231515.aspx[^]) So you might want to surround the CONCAT(..) with a TRIM(..).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Since it's the same table you can just write it like this:
SELECT
Label
, CONCAT(BFirstName, ' ', BLastName) AS BAttention
, BCity
FROM CardInfoPerm
WHERE CardID = 1121jkirkerx wrote:
not sure if it's safe
If you're thinking about null-values:
Quote:
Null values are implicitly converted to an empty string. If all the arguments are null, an empty string of type varchar(1) is returned.
(From https://msdn.microsoft.com/en-us/library/hh231515.aspx[^]) So you might want to surround the CONCAT(..) with a TRIM(..).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
You're welcome! :)
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson