gpt4 book ai didi

php - GROUP_CONCAT 奇怪的结果

转载 作者:行者123 更新时间:2023-11-29 08:51:54 27 4
gpt4 key购买 nike

我尝试使用 group_concat 来更快地创建 xml 输出。与传统查询相比,记录数不同。事实上,当我的查询使用组连接时,我的记录较少。

    SELECT GROUP_CONCAT(
CONCAT('\n<p>\n',
CONCAT('\n<id>',paIndex,'</id>\n'),
CONCAT('<prInitiales>',prInitiales,'</prInitiales>\n'),
CONCAT('<paNomPren>',paNomPrenom,'\n',ttT_Traitement_P,'</paNomPren>\n'),
CONCAT('<ttTStatutP>',ttTStatutP,' - ',DATE_FORMAT(ttDateStatut,'%d/%m/%Y'),'\n',ttUserImportant,'</ttTStatutP>\n'),
CONCAT('<paDossier1>',paDossier1,'\n',paDossier2,'</paDossier1>\n'),
CONCAT('<paNumTel1>',paNumTel1,'\n',paNumTel2,'</paNumTel1>\n'),
CONCAT('<paNaissanceS>',DATE_FORMAT(paNaissance,'%d/%m/%Y'),'</paNaissanceS>\n'),
'</p>') ORDER BY paNomPrenom DESC) AS xml
FROM 20Patients_1012
JOIN 30Traitemnt_201223 ON 20Patients_1012.paIndex = 30Traitemnt_201223.ttIndex
JOIN 12Praticien_02 ON 30Traitemnt_201223.ttPraticien = 12Praticien_02.prIndex

传统查询:

    SELECT 20Patients_1012.paIndex, 20Patients_1012.paNomPrenom, 20Patients_1012.paDossier1, 20Patients_1012.paDossier2, 20Patients_1012.paNaissance, 20Patients_1012.paNumTel1, 30Traitemnt_201223.ttTStatutP, 30Traitemnt_201223.ttDateStatut, 12Praticien_02.prInitiales
FROM 20Patients_1012
JOIN 30Traitemnt_201223 ON 20Patients_1012.paIndex = 30Traitemnt_201223.ttIndex
JOIN 12Praticien_02 ON 30Traitemnt_201223.ttPraticien = 12Praticien_02.prIndex ORDER BY 20Patients_1012.paNomPrenom ASC

感谢您的帮助

最佳答案

the manual 中所述:

The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer:

SET [GLOBAL | SESSION] group_concat_max_len = val;

关于php - GROUP_CONCAT 奇怪的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10934025/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com