0
が存在する場合、私は二つのテーブル持ってどこでどのように使用できるかを参加: - >左は右のフィールドが
|uuid|name|last_name|email|rol |status|
|1234|abcd| abc |[email protected]|pre-thunder| 1 |
|5678|efgh| efg |[email protected]|pre-thunder| 1 |
そしてdocumentation_thunderテーブル(クエリで使用されるフィールド) - (クエリで使用されるフィールド)
ユーザーを>
|id|id_thunder|doc_type|
|1 |1234 |image |
私は私の左のテーブルの上にすべてのレコードを取得しようとするが、追加は、私は私の右のテーブルからカウントを取得:
SELECT
users.uuid,
users.email,
users.name,
users.last_name,
COUNT(documentation_thunder.id) as documentation// i need to know how many documents have the user
FROM users
LEFT JOIN documentation_thunder
ON users.uuid = documentation_thunder.id_thunder
WHERE
users.status = 1 AND users.rol = 'pre-thunder' AND (documentation_thunder.doc_type = 'image' OR documentation_thunder.doc_type IS NULL)
このクエリは最初のユーザーのみを返しますが、文書がない場合でもすべてのユーザーが返す必要があります。
どうすればいいのですか?
あなたは最高です。ありがとうGiorgos –