guess i'll just ask:
here are the 2 tables of interest:
mysql> select * from ticket_details;
+--------------------------------------
+--------------------------------------+----------+
| ticket | product
| quantity |
+--------------------------------------
+--------------------------------------+----------+
| 9f2d7b86-213d-1028-88b7-09e76b61a517 |
85d0d5bc-213c-1028-88b7-09e76b61a517 | 1 |
| 9f2d7b86-213d-1028-88b7-09e76b61a517 |
ad67557e-213c-1028-88b7-09e76b61a517 | 3 |
| ec04c91e-2142-1028-88b7-09e76b61a517 |
60e766f8-213c-1028-88b7-09e76b61a517 | 7 |
| ec04c91e-2142-1028-88b7-09e76b61a517 |
a4341a8c-213c-1028-88b7-09e76b61a517 | 2 |
+--------------------------------------
+--------------------------------------+----------+
mysql> select * from product;
+--------------------------------------+--------+-------+
| id | name | price |
+--------------------------------------+--------+-------+
| 60e766f8-213c-1028-88b7-09e76b61a517 | banana | 1.98 |
| 85d0d5bc-213c-1028-88b7-09e76b61a517 | orange | 0.97 |
| a4341a8c-213c-1028-88b7-09e76b61a517 | apple | 0.89 |
| ad67557e-213c-1028-88b7-09e76b61a517 | pear | 1.09 |
+--------------------------------------+--------+-------+
here's a functional join that retrieves some specifics from a given
ticket #:
select ticket_details.quantity,
product.name,
product.price,
(product.price * ticket_details.quantity) as subtotal
from product,
ticket_details
where ticket_details.ticket = '9f2d7b86-213d-1028-88b7-09e76b61a517'
AND
ticket_details.product = product.id
;
+----------+--------+-------+----------+
| quantity | name | price | subtotal |
+----------+--------+-------+----------+
| 1 | orange | 0.97 | 0.97 |
| 3 | pear | 1.09 | 3.27 |
+----------+--------+-------+----------+
how can i also show a grand total for the ticket (without changing the
table structure)? i've tried with no success to use SUM() to do this.
would i even use SUM()?
if i could refer to the resultant table above in a subsequent select,
that would be ideal. is there a way to do that (something like select
SUM(@@result.subtotal);)?
thanks.
- philip
On May 28, 2005, at 11:36 PM, Philip George wrote:
is it okay to post a basic sql join question to this list?
if not, please point me to a list for these types of questions.
thanks.
- philip
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]