Display php question/problem

Discussion in 'PHP' started by seofx, Apr 30, 2009.

  1. #1
    ok i know how to connect to the mysql database and all that jazz. The question i have is lets say i have 2 columns: 1)city(ex. baltimore) 2)food(ex. cookies) there are several cities in the database and they reappear all the time, same with the food column what i want to show is a list of cities where lets say the food 'cookies' appears most often and ordered from most to least, and also wondering how i can have it only show all the cities with cookies has come up in the food column atleast 5 times
     
    seofx, Apr 30, 2009 IP
  2. sliver

    sliver Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use the "group by", try a query like:

    select cookie, count(cookie) as count, city from comments group by cookie order by count desc

    use "where"
    .....where cookie > 4

    I suggest to read any basic sql tutorial
    ;)
     
    sliver, Apr 30, 2009 IP