php/mysql grouping output
| From: | Kelly Meeks | Date: | Sun, 09 Mar 2003 19:56:31 +0000 |
| Subject: | php/mysql grouping output | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138875@lists.php.net to get a copy of this message | ||
I've got a multi-table query, (pulling from both an orders and an orders_products (line items)
file), and I'd like to group the output to help reduce multiple appearances of of the product
skus.
The query:
select
orders.orders_id,orders.date_purchased,orders.customers_name,orders_products.products_name,orders_products.products_model,orders_products.products_quantity,
orders_products.products_price from orders,orders_products where
orders.date_purchased='2003-01-01' and orders.orders_id=orders_products.orders_id order by
orders_products.products_model
You get output like
Order Num Order Date Product Code Product Name
---------------------------------------------------------------------------------------
1 2003-01-01 12345 product xyz
2 2003-01-01 12345 product xyz
3 2003-01-01 abcde product abc
1 2003-01-01 abcde product abc
5 2003-01-01 12345 product xyz
If I wanted to have the output grouped on any of the fields, how would I go about doing it?
TIA
Kelly