Line break within a MYSQL query

Asked

Viewed 780 times

0

Hello someone can help me with line breaking within a mysql query?

The code goes like this:

CONCAT('Origem -> ',vEnderecoOrigem,' \r\nDestino ->',vEnderecoDestino)

The result:

Origem -> Rua Exemplo Origem Destino -> Rua Exemplo Destino

Expected result:

Origem -> Rua Exemplo Origem 
Destino -> Rua Exemplo Destino

I tried the CHAR(10),(13),\n and I can’t get the expected result. It’s possible to do this?

Note: It is a generator .pdf and .xls, the name is FPDF.

  • In PHP use the function nl2br

  • How are you doing to check the result? If you’ve tried all this, it’s probably in your application or test, not in the query. Virtually every decent Mysql tool (like the "dead" Mysql Query Browser, for example) lets you see the binary fields to be sure.

  • I tried with nl2br and it printed <br /> together. Next I am modifying the output values of a report. The application is printing everything ok, the problem is that the addresses are large so I need the line break to facilitate visualization. I’ve used other tools to generate PDFS only this one in particular when I try to insert HTML it doesn’t answer... I have no idea what it might be.

  • I believe it is not a Mysql operation

2 answers

1

You can use the CONCAT_WS, should solve the problem:

CONCAT_WS('\n', 'Origem -> '.vEnderecoOrigem, 'Destino ->'.vEnderecoDestino)
  • 2

    This is not the author’s problem. CONCAT_WS gives anyway. See comments, it is recording the break, the problem is in its application. BR is in DB, but the code that generates the PDF is not correct (actually the question is out of scope - problem not reproduced, because it does not proceed to the statement - the author would have to update the question with the real situation)

  • 1

    I got it, I got it solved thanks.

0


Really the problem was not in the query but in the application. I found the solution on the FPDF site using a Multicell, this function already creates a cell and breaks the lines depending on the size of the string. Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.