Mysql GROUP CONCAT 使用注意事項

2021-08-18 08:36:44 字數 1373 閱讀 4642

group_concat 函式返回乙個字串結果,該結果由分組中的值連線組合而成,常和 group by 連用。

如果需要自定義分隔符可以使用 separator。

示例:select group_concat(id) ids from sys_oem_resources where pid is not null group by pid;

注意示例:

別亂用 group_concat,說不定你現在使用的 group_concat 得到的結果就是隱藏著bug的。

group_concat 的結果會受到 group_concat_max_len 變數的限制。

預設 group_concat_max_len = 1024,即字串的長度位元組超過1024 則會被截斷。

通過命令 "show variables like 'group_concat_max_len' " 來檢視 group_concat 預設的長度:

mysql> show variables like 'group_concat_max_len';

+----------------------+-------+

| variable_name | value |

+----------------------+-------+

| group_concat_max_len | 1024 |

+----------------------+-------+

1 row in set

在mysql配置檔案中新增配置:group_concat_max_len = -1  (-1為最大值或根據實際需求設定長度),配置後需要重啟mysql服務,檢視如下所示:

mysql> show variables like 'group_concat_max_len';

+----------------------+------------+

| variable_name | value |

+----------------------+------------+

| group_concat_max_len | 4294967295 |

+----------------------+------------+

1 row in set

Protocol Buffers使用注意事項

protocol buffers做為廣泛使用的乙個序列化開源庫,提供了很多語言下的支援,本文就談談msvc c 使用pb遇到的問題,當然這些問題因為每個人的使用模式不同,可能都不一樣,本文也不討論怎麼寫proto及編譯。我們使用pb做序列化可以把pb生成靜態庫或者動態庫 libprotobuf.dl...

C using namespace使用注意事項

一 using 用法 1.引用命名空間。如 using system 2.自動釋放物件使用的資源。如 using sqlconnection connection new sqlconnection connectionstring connection.open 當鏈結使用完畢以後,將自動釋放sq...

關於better scroll的使用注意事項

1.動態載入資料需要重新整理滾動區域 this.nexttick 2.滾動區域上的事件,需要在註冊滾動的時候,新增 click true mounted 3.預設 y軸 滾動,需要x軸滾動,新增 scrollx true 4.上拉載入功能,註冊時需要申明,pullupload 可以為true 或者如...