Add New Line in MySQL with Concat

We know what to retrieve when changing data into a different format or performing data analysis, but we may get stuck on how to access it. This is a circumstance while working with MySQL in which I need to concatenate two strings that should return the data in different lines. Obviously, different approaches will be taken for each implementation.

MySQL Code:

SET @sql1 = ‘DELIMITER //’;
SET @sql2 = ‘USE TestDB2 //
CREATE PROCEDURE sometest(p1 int, p2 int)
BEGIN
select ”Hai”;
END //
;
SELECT CONCAT(@sql1 , CHAR(13), @sql2);

The result is as follows:

DELIMITER //
USE TestDB2 //
CREATE PROCEDURE sometest(p1 int, p2 int)
BEGIN
select ‘Hai’;
END //

Hope you find it helpful.

Please subscribe for more interesting updates.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s