I have 2 tables, and I'm trying to make one query to save myself some work.
Table 1: id, category id, colour Table 2: category id, category name
I want to join them to get id, category id, category name, colour
Then I want to limit it so that no red elements are selected ( WHERE colour != "red" ) Then I want to count the number of records in each category ( COUNT(id) GROUP BY (category id ).
I have tried:
SELECT COUNT(table1.id), table1.category_id, table2.category_name FROM table1 INNER JOIN table2 ON table1.category_id=table2.category_id WHERE table1.colour != "red"
But that just doesn't work. I have tried many options and do not get any results when I try to execute the above query.
source share