I have a query where projects are joined with tasks by an id. A project has many tasks. This is what the query looks like:
select project.projectname, task.taskname, project.projectid
from project, task
where (project.projectid = task.projectid) and (project.status = 0)
Now, according to the SQL, it should only query according to those conditions, meaning only if a project has a task. My questions is: what do I need to change so it also returns the projects that have no tasks (and have a status of 0 as shown in the query)? I guess it would be like a union maybe, but haven't been successful at uniting the two query results. Any thoughts?
I would like to do the same thing with this query:
select project.*, user.first_name, user.last_name, user.user_name, count(task.projectid) as tasks
from project, user, task
where (project.creator = user.user_id) and (project.projectid = task.projectid) and (project.status = 0)
group by project.projectname
order by tasks
Any help is appreciated. Thanks!