รองรับได้ ต้องตั้งค่า sql_mode = PIPES_AS_CONCAT ไวยากรณ์:
set sql_mode = PIPES_AS_CONCAT;
ต่อสตริงด้วย ||:
SELECT 'yourValue' || yourColumnName AS anyAliasName FROM yourTableName;
สร้างตาราง:
mysql> create table PipeConcatDemo ( Name varchar(20) ); Query OK, 0 rows affected (0.93 sec)
แทรกข้อมูล:
mysql> insert into PipeConcatDemo values('Larry'); Query OK, 1 row affected (0.18 sec) mysql> insert into PipeConcatDemo values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into PipeConcatDemo values('Maxwell'); Query OK, 1 row affected (0.23 sec) mysql> insert into PipeConcatDemo values('Bob'); Query OK, 1 row affected (0.17 sec)แสดงข้อมูล:
mysql> select * from PipeConcatDemo;
ผลลัพธ์:
+---------+ | Name | +---------+ | Larry | | John | | Maxwell | | Bob | +---------+ 4 rows in set (0.00 sec)
ตั้งค่า sql_mode แล้วต่อสตริง:
mysql> set sql_mode = PIPES_AS_CONCAT; Query OK, 0 rows affected (0.00 sec) mysql> select 'Good Morning !!! ' || Name AS PipeConcatenationDemo from PipeConcatDemo;
ผลลัพธ์:
+--------------------------+ | PipeConcatenationDemo | +--------------------------+ | Good Morning !!! Larry | | Good Morning !!! John | | Good Morning !!! Maxwell | | Good Morning !!! Bob | +--------------------------+ 4 rows in set (0.00 sec)