如何正确连接SQL中的表?

时间:2017-03-11 10:49:34

标签: mysql sql

我有这样的表结构:

table 1: akdmst_mahasiswamagister (ID, NIM, MayorID, TahunMasuk)
table 2: akdmst_mayor(ID, Nama)
table 3: akdhis_kelanjutanstudi(ID, NIM, IPK)

这是我做的sql代码:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `a1111` AS select 
`akdmst_mahasiswamagister`.`NIM` AS `NIM`,
`akdmst_mayor`.`Nama` AS `Nama`,
`akdhis_kelanjutanstudi`.`IPK` AS `IPK`,
`akdmst_mahasiswamagister`.`TahunMasuk` AS `Tahun Masuk`
from ((`akdmst_mahasiswamagister` left join `akdmst_mayor` on((`akdmst_mahasiswamagister`.`MayorID` = `akdmst_mayor`.`ID`)))
left join `akdhis_kelanjutanstudi` on((`akdmst_mahasiswamagister`.`NIM` = `akdhis_kelanjutanstudi`.`NIM`)));

但是当我尝试运行它时,IPK的数据输入结果为NULL。实际上,IPK有自己的价值。我该怎么做才能解决它?三江源

0 个答案:

没有答案