Need help with writing SQL..

Discussion in 'Databases' started by ziya, Oct 1, 2007.

  1. #1
    Hello all,

    Please help me if you can ..

    Have table category, and table websites.

    how to show category names and count of websites in each category....


    Thank you in advance
     
    ziya, Oct 1, 2007 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    assuming you've got a table named websites with a column of url's and a column of categories..

    select category_column, count(*)
    from websites
    group by category_column
     
    Jamie18, Oct 1, 2007 IP
  3. jakomo

    jakomo Well-Known Member

    Messages:
    4,262
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    138
    #3
    you need to make a joint beteween tables :)
     
    jakomo, Oct 1, 2007 IP
  4. trailerpark

    trailerpark Peon

    Messages:
    37
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you could show us the 'describe' (ie. in SQL query: desc category) of the tables in question I'm sure that you would receive the exact query that you are looking for.

    ...and yes, you would need to use an aggregate function (such as COUNT).
     
    trailerpark, Oct 10, 2007 IP