Search code examples
biginsightsbigsql

Nested Concatenation in BigSQL


I'm attempting to concatenate three fields in BigSQL. I can successfully concatenate two fields with

SELECT
CONCAT(column1, column2)
FROM table;

but I am unable to concatenate three fields with that (only accepts two arguments). I have attempted a nested concatenation via

SELECT
CONCAT(CONCAT(column1, column2), column3)
FROM table;

But this returns a Null value. I'm attempting to create a view but this part of the select statement isn't working. All three columns are varchar so I'm not sure where the issue is, unless I literally am just not allowed to do nested concatenations.


Solution

  • The answer is to pay attention to your data. The third column I was concatenating was defined as varchar(1) but every single row had read in " " and apparently read it as Null. When we are concatenating anything with a NULL, the result will be NULL. When I ran this code with a different third column it successfully concatenated.