Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove embeded newline character in a big query table column using a function

I have a big query table with a column that has embedded new line character. I want to remove it using a function. It has to be a done using function and I cannot use properties like allowQuotedNewlines etc. I tried below and it is not working. Appreciate your help here.

select replace(column,'\\n','') from table
like image 799
Lijju Mathew Avatar asked Nov 02 '25 16:11

Lijju Mathew


1 Answers

Without seeing your SQL or the error, it's hard to know what you're doing wrong. But REPLACE works just fine for me:

SELECT
  new_line_delims,
  REPLACE(new_line_delims, '\\n', '') AS new_line_delims_replaced
FROM (
  SELECT
    '\\nThis has several embedded\\n new line delims\\n' AS new_line_delims)
like image 189
Graham Polley Avatar answered Nov 05 '25 14:11

Graham Polley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!