我这样查询:
select a.NIM
, k.IPK
, m.nama Mayor
from kelanjutanstudi k
left
join mahasiswamagister a
on k.ID =a.MahasiswaID
left
join mayor m
on m.ID = a.MayorID
当我试图运行它时,结果并不像我预期的那样。因为结果是这样的
实际上,NIM和Mayor有自己的价值,但是当我运行查询时,NIM和Mayor的值为NULL。也许,我的sql代码有问题。这是我的表:
mahasiswamagister表
kelanjutanstudi表
请帮我解决这个问题。三江源
答案 0 :(得分:0)
将left join
更改为Inner Join:
select
`mahasiswamagister`.`NIM` AS `NIM`,
`kelanjutanstudi`.`IPK` AS `IPK`,
`mayor`.`Nama` AS `Mayor`
from ((`kelanjutanstudi`
inner join
`mahasiswamagister`
on((`kelanjutanstudi`.`ID` = `mahasiswamagister`.`MahasiswaID`)))
inner join
`mayor`
on((`mayor`.`ID` = `mahasiswamagister`.`MayorID`)))