如何将该查询转换为内部联接

时间:2018-10-24 09:30:37

标签: sql

SELECT * FROM fihrist,fihristAyet,ayetler,sureler WHERE
fihrist.fihrist_id=fihristAyet.fihristAyet_fihrist_id AND
fihristAyet.fihristAyet_ayet=ayetler.ayet_no AND
fihristAyet.fihristAyet_sure_id=ayetler.sure_id AND
fihristAyet.fihristAyet_sure_id=sureler.sure_id AND
fihristAyet.fihristAyet_fihrist_id=564

我该如何处理内部联接。我尝试了此代码,但没有。

SELECT * FROM fihrist
INNER JOIN fihristayet ON fihrist.fihrist_id=fihristayet.fihristAyet_id
INNER JOIN ayetler ON fihristayet.fihristAyet_ayet=ayetler.ayet_no AND fihristayet.fihristAyet_sure_id=ayetler.sure_id
INNER JOIN sureler ON fihristayet.fihristAyet_sure_id=sureler.sure_id
WHERE fihristayet.fihristAyet_fihrist_id=564

1 个答案:

答案 0 :(得分:0)

我认为您可以做到;

SELECT * 
FROM fihrist f
 INNER JOIN fihristAyet fa
    ON f.fihrist_id=fa.fihristAyet_fihrist_id
 INNER JOIN ayetler ay
    ON fa.fihristAyet_ayet=ay.ayet_no
 INNER JOIN sureler s 
    ON fa.fihristAyet_sure_id = s.sure_id AND fa.fihristAyet_sure_id = ay.sure_id
WHERE fa.fihristAyet_fihrist_id=564