0
我已經找到了解我的查詢出了什麼問題。我選擇'acara'和'eventorg'表, 如果'acara'未找到或空, 表'eventorg'不想顯示, 但如果表'acara'不爲空或找不到, 表'eventorg' 「並表‘阿卡拉’將顯示當一個表爲空或不爲空時選擇兩個表格
這是我的查詢
SELECT
eventorg.nama as NamaEO,
eventorg.deskripsi as DeskEO,
eventorg.logo as LogoEO,
eventorg.email as EmailEO,
eventorg.telp as TelpEO,
acara.nama as NamaEvent,
acara.id_acara,
acara.tanggal,
acara.deskripsi,
acara.lokasi
FROM eventorg
LEFT JOIN acara
ON acara.id_eo=eventorg.id_eo AND eventorg.id_eo='$ideventO';
'表‘eventorg id_eo’是主鍵,‘’表‘阿卡拉id_eo’是外鍵
閱讀:http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/ –
謝謝@MatthewHerbst,它確實有用 – Rei