Wednesday, 11 September 2013

SQL query Selecting categories and details without repeating

SQL query Selecting categories and details without repeating

I am writing a very simple sql query but for some reason I am unable to
pull it through. I have mysql table with the following fields; cities,
towns and persons. There are several cities, with several towns, which
have several people. I want to be able to select a city, say London and be
able to see all the towns under london and be able to see everyone living
in those towns. What is happening at the moment is that when I query all
the tables using their ids, I get a repeat of categories.
I am attaching a picture of what I am trying to achieve
What I am achieveing is city1 -town1 - person1 city1-town 2-person 1
I do not want the city to repeat, but at the same time I want a list of
everything in that city

No comments:

Post a Comment