I have two tables like these: (Docs)
| Id | Name |
|---|---|
| 1 | Doc1 |
| 2 | Doc2 |
and
(Signs)
| Id | personId | docId | SignedAt |
|---|---|---|---|
| 1 | 1 | 1 | 2023-01-01 |
| 2 | 3 | 2 | 2023-01-02 |
So I want to get details of docs for each user. for instance I need a list to show that user with Id = 1 like this:
(result)
| DocId | signedAt |
|---|---|
| 1 | 2023-01-01 |
| 2 | null |
I tried Left Join like below:
SELECT * from docs
LEFT JOIN Signs on docid = docs.id
where Signs.personId = 1 || Signs.personId is null;
but it just returns the first line of the result table. how could I generate my desired result?