私はusers
テーブルと3つのテーブルにユーザーの収入があります。
私がしようとしているのは、これらの3つのテーブルに基づいて最も収益の高い上位10人のユーザーを選択することです。
私は昨日からこの要求に苦労しており、私はそれを動作させることができません。
合計3つの収益テーブルを合計します。3つのテーブルから合計収益を得る
お願いします。
SELECT
users.first_name,
users.last_name,
(select SUM(`value`) from `earnings1` where users.id = earnings1.user) as earnings1,
(select SUM(`value`) from `earnings2` where users.id = earnings2.user) as earnings2,
(select SUM(`value`) from `earnings3` where users.id = earnings3.user) as earnings3,
(earnings1 + earnings2 + earnings3) as total
FROM users
GROUP BY users.id
ORDER BY total DESC
LIMIT 10
私は今取得していますエラーは次のとおりです。
'フィールドリスト' 内の不明な列 'earnings1'
エラーは何ですか? – MontyPython
今、 '不明な列 'フィールドリスト'の 'earnings1' ' – divHelper11
そして、' earnings1'テーブルの列は何ですか? –