Vote count:
0
I have a table with a list of cities.
I have another table with a table of listings.
How do I query the list of cities and include a column with the total number of listings for that city?
I have:
SELECT a.*,(SELECT COUNT FROM tbl_listings WHERE city=a.id) AS cnt FROM tbl_cities
Database Structure(ish)
CITIES
ID | CITY
01 | Atlanta
02 | Boston
LISTINGS (one example)
ID | CTY| DETAILS
01 | 01 | Listing 1
02 | 01 | Listing 2
DESIRED RESULT
01 | Atlanta | 345
02 | Boston | 43
asked 1 min ago
How do you query a list from a table and include its total matches from a sub table
Aucun commentaire:
Enregistrer un commentaire