I have two database tables, 'Lists' and 'Notes'.
Lists has columns _id, listname
Notes has columns _id, checked, list_id (which is a foreign key of Lists._id), and more columns that aren't relevant to this question.
I would like to create a query that returns four columns:
Lists._id, Lists.listname, the count of all checked Notes in this list, the count of all Notes in this list.
The query should return all entries from Lists.
I can get the counts and the _ids & listnames seperately, using the following queries
SELECT _id, listname FROM Lists
SELECT count(checked) FROM Notes WHERE checked='1' and list_id=foo_id
SELECT count(*) FROM Notes WHERE list_id=foo_id
In these statements, foo_id refers to the _id of the list I would like to count checked and total items for.
Could someone show me how I could put these all into one query?
Bonus points for throwing an AS in there for the count columns.