* Mike Morton 
> Runnint Mysql 3.23.47
> 
> I have the following two tables:
> backorder_notification
>     ->product_code varchar
>     ->email varchar
>     ->date_added date
> Products
>     ->code varchar
>     ->name varchar
>     ->other stuff that is not important
> 
> Essencially - I want to get a count of the product codes that are in the
> backorder_notification table ordered by count then by product name and
> output the display:
> 
> Code    Name    Count

You can join them all, group, count and order in the same query:

SELECT 
    product_code,                         
    name,                                 
    count(product_code) as total          
  FROM backorder_notifications,products
  WHERE
    backorder_notifications.product_code = products.code
  GROUP BY product_code, name
  ORDER BY total

HTH,

-- 
Roger

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to