gpt4 book ai didi

MySQL 不返回空列连接值

转载 作者:行者123 更新时间:2023-11-29 11:31:00 25 4
gpt4 key购买 nike

我有这 4 个表:
tables

我的预期结果:
expected result

这是我当前的查询(来自 here 的帮助)

select a.No_Registrasi, a.Nama_CTKI, b.Nama_Negara, CONCAT('RA-', MAX(substring(c.ID_Rad, 4) + 0)) AS ID_Rad, CONCAT('Lab-',MAX(substring(d.ID_Lab, 5) + 0)) AS Id_Lab
FROM tb_registrasi a
JOIN tb_negara_tujuan b
ON a.ID_Negara = b.ID_Negara
JOIN tb_radiologi c
ON a.No_Registrasi = c.No_Registrasi
JOIN tb_laboratorium d
ON a.No_Registrasi = d.No_Registrasi
GROUP BY a.No_Registrasi, a.Nama_CTKI, b.Nama_Negara

这是查询的结果:
enter image description here

如何获得我期望的结果?我对这样的高级查询真的没有经验,非常感谢任何帮助。谢谢。

最佳答案

希望这有帮助。

select a.No_Registrasi, a.Nama_CTKI, b.Nama_Negara, CONCAT('RA-', MAX(substring(c.ID_Rad, 4) + 0)) AS ID_Rad, CONCAT('Lab-',MAX(substring(d.ID_Lab, 5) + 0)) AS Id_Lab
FROM tb_registrasi a
LEFT JOIN tb_negara_tujuan b
ON a.ID_Negara = b.ID_Negara
LEFT JOIN tb_radiologi c
ON a.No_Registrasi = c.No_Registrasi
LEFT JOIN tb_laboratorium d
ON a.No_Registrasi = d.No_Registrasi
GROUP BY a.No_Registrasi, a.Nama_CTKI, b.Nama_Negara

关于MySQL 不返回空列连接值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37429695/

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