I have a table that is used for reference (number), as follows
----------------------------
Id | Name | Description |
----------------------------
1 One The number one
2 Two The number two
3 Three The number three
And then another table (user_number) that references these values but for specific users
--------------------------
Id | User_Id | Number_Id |
--------------------------
1 400 1
2 400 2
I want to retrieve all the results of the first table but I want to see where they match up also. I have tried to use the following query but it only returns what an INNER JOIN would return
SELECT n.Id, n.Name, n.Description, un.Id As Active_Number
FROM number n
LEFT JOIN user_number un
ON n.Id = un.Id
WHERE un.User_Id = 400;
This query returns:
[
{
"Id": 1,
"Name": "One",
"Description": "The number one",
"Active_Number": 1
},
{
"Id": 2,
"Name": "Two",
"Description": "The number two",
"Active_Number": 2
}
]
However this doesn't return the third set of values from the number table.