MySQL 租户的字符串连接函数是 concat 、 concat_ws, ’||’ 默认是表示逻辑运算符`或`。
如查看 MySQL 租户下的客户姓名,SQL语句如下:
obclient> SELECT concat_ws(' ', c_first, c_last) full_name FROM cust ORDER BY c_last LIMIT 2;
+---------------------------+
| full_name |
+---------------------------+
| fvBZoeIV2uJh7 ABLEABLEESE |
| dHmIgRV1IsC ABLEABLEOUGHT |
+---------------------------+
2 rows in set (0.01 sec)
如果把 MySQL 租户下的变量 sql_mode 值增加一个选项 PIPES_AS_CONCAT ,则 ’||’ 也会当作字符串连接符。SQL语句如下:
obclient> SET SESSION sql_mode='PIPES_AS_CONCAT,STRICT_TRANS_TABLES,STRICT_ALL_TABLES';
obclient> SELECT c_first || ' ' || c_last full_name FROM cust ORDER BY c_last LIMIT 2;
+---------------------------+
| full_name |
+---------------------------+
| fvBZoeIV2uJh7 ABLEABLEESE |
| dHmIgRV1IsC ABLEABLEOUGHT |
+---------------------------+
2 rows in set (0.01 sec)