2 つのリレーション テーブルに依存するテーブルからユーザーを選択したい
構造:
[user]
uid | firstname | lastname | ...
---------------------------------
482 | USERa | USERa | ...
885 | USERb | USERb | ...
405 | USERc | USERc | ...
385 | USERd | USERd | ...
[news_info]
uid_local | uid_foreign
--------------------------------
125 | 482
100 | 405
[news_add]
uid_local | uid_foreign
--------------------------------
125 | 885
105 | 385
[news_info] と [news_add] から uid_local -> 125 で USERa と USERb のみを選択したい
SELECT
nnfo.uid_local,
user.*
FROM user
JOIN news_info nnfo
ON nnfo.uid_foreign = user.uid
WHERE nnfo.uid_local = 125
result = USERa // 動作します
SELECT
nadd.uid_local,
user.*
FROM user
JOIN news_add nadd
ON nadd.uid_foreign = user.uid
WHERE nadd.uid_local = 125
result = USERb // 動作します
SQLステートメントを1つに「マージ」します... USERaとUSERbを取得します
SELECT
nnfo.uid_local,
nadd.uid_local,
user.*
FROM user
JOIN news_info nnfo
ON nnfo.uid_foreign = user.uid
JOIN news_add nadd
ON nadd.uid_foreign = user.uid
WHERE nnfo.uid_local = 125 AND nadd.uid_local = 125
result = empty // エラーなし.....
何が悪いの...私はいくつかの他のステートメントを試しましたが、結果はありません:(