I have the following table:
explain domain_payments;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| Invid | int(11) | | | 0 | |
| Custid | int(11) | | | 0 | |
| Date | date | YES | | NULL | |
| Description | varchar(80) | YES | | NULL | |
| Domain | varchar(150) | YES | | NULL | |
| UnitPrice | double | YES | | NULL | |
| Quantity | int(11) | | | 0 | |
| Amount | double | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
My goal is to create a table with the latest payment date and invoice id for
each domain. This is what I did:
create table t select domain,max(invid) as invid
from domain_payments group by domain;
alter table t add date_paid date;
update t,domain_payments as tr set date_paid=date where t.invid=tr.invid;
The above worked fine for the number of records in my dataset. In learning
[my]sql I am trying to see how this would best be done with a large dataset as
well more efficiently in general.
Thanks for any pointers.
_____
Douglas Denault
http://www.safeport.com
[EMAIL PROTECTED]
Voice: 301-469-8766
Fax: 301-469-0601
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]