I have the following two tables:
projects_expended:
+---------------+------------+----------+
| project_name | project_id | Utilised |
+---------------+------------+----------+
| CStreamTax | 1 | 3500 |
| CStreamTravel | 2 | 149 |
+---------------+------------+----------+
projects:
+------------+---------------------+
| project_id | project_budgetstart |
+------------+---------------------+
| 1 | 15000 |
| 2 | 15000 |
| 3 | 500 |
+------------+---------------------+
I would like to make a joint table of the two, but with the Utilised
field filled with NULL
when a project_id form the projects table does
not match one of the entries in the projects_expended table.
My basic attempt was as follows:
SELECT projects.*, projects_expended.utilised
FROM projects_expended
JOIN projects
ON projects.project_id = projects_expended.project_id;
And the result:
+------------+---------------------+----------+
| project_id | project_budgetstart | utilised |
+------------+---------------------+----------+
| 1 | 15000 | 3500 |
| 2 | 15000 | 149 |
+------------+---------------------+----------+
I understand why I get the result I get. But I'm pretty stuck with this. I've made other attempts (too many to count).