Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Unanswered: How to count records from two tables

    I have two tables named categories and products, structure of tables is like below:

    Categories(category_id,category_name)

    1, ajax
    2, adobe
    3, software dev
    4, database

    products(product_id,product_name,category_id)

    1, dbbooks, 4
    2, software practice, 3
    3, dreaviewver, 3
    4, hide-show, 1

    This is sample reults, Result should display like this:
    1 ajax(1)
    2 adobe(0)
    3 software dev(2)
    4 database(1)
    I shall be very thankful...........Please help me....... Suresh

  2. #2
    Join Date
    Aug 2010
    Posts
    2

    How to count records from two tables

    I have two tables named categories and products, structure of tables is like below:

    Categories(category_id,category_name)

    1, ajax
    2, adobe
    3, software dev
    4, database

    products(product_id,product_name,category_id)

    1, dbbooks, 4
    2, software practice, 3
    3, dreaviewver, 3
    4, hide-show, 1

    This is sample reults, Result should display like this:
    1 ajax(1)
    2 adobe(0)
    3 software dev(2)
    4 database(1)
    I shall be very thankful...........Please help me....... Suresh

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    let me give you three hints:

    1, LEFT OUTER JOIN
    2, COUNT()
    3, GROUP BY

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Sep 2010
    Posts
    1

    Talking agreed

    i have toagree

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •