www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] List of items with count of each item

  1. #1
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440

    resolved [RESOLVED] List of items with count of each item

    Trying to issue a MySQL query that will retrieve a list of items and the number of each item
    There are more columns than shown, but each Item will have entries in multiple rows.
    Table
    Item1
    Item1
    Item1
    Item2
    Item2
    Item3
    Item4
    Item4

    query would return

    Item1 , 3
    Item2 , 2
    Item3 , 1
    Item4 , 2

    Thanks in advance

    My first attempt was

    SELECT Item, COUNT(Item) FROM table ORDER by Item

    But it only returned one row with the first Item encountered and a total of all row.

    And SELECT DISTINCT Item, COUNT(Item) FROM table ORDER by Item

    did the same

  2. #2
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    Ok got it working

    SELECT Items, COUNT(Items) FROM `mytable` WHERE Col1 LIKE '1%' GROUP BY Items

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles