dimanche 1 mai 2016

SQL - Select Rows based on this criteria

I'm using SQLite 3, and cannot work out how to do this!

Just wondered if anyone could give any tips. I have two tables, for example:

Table: chefs

Name    | Gender
Alice   | Female
Billy   | Female
Charlie | Male
Dillon  | Male


Table: dishes

Dish      | Name
Steak Pie | Alice
Lasagne   | Billy
Burger    | Alice
Salad     | Charlie
Fries     | Dillon

What I want is to display how many dishes there are, which are prepared by females (obviously, this needs to use information from both tables)

I'm expecting a similar result to the following:

Name    | NumberOfDishes
Alice   | 2
Billy   | 1

As the above is recognising that these are the only female chefs using data from the first table, and counting how many dishes these individual chefs have in the second table.

Any ideas on how this can be achieved?

Many thanks!!!!!

Aucun commentaire:

Enregistrer un commentaire