Question. I have two tables donation_test, and max_donation. The max donation table is a summary table, used to keep the max donation for each contact_id, by listing its donation_id. We have decided to use database level triggers to keep the summary table (max_donation) table up to date. I have been looking at the looping of a cursor syntax but am a little lost. Would someone mind taking the time to show me how exactly the syntax would look.
For example if i run an update on donation_id 126 and change the amount equal to then 2000.00 then update after trigger should search though all the donations made by NEW.contact_id, figure the highest amount, then insert that into the max_donation table, also, and here is the tricky part, if there are two or more donations with the same amount, they all must be inserted into the max_donation table. mysql> select * from donation_test; +-------------+------------+----------------------------+ | donation_id | contact_id | donation_date|total_amount | +-------------+------------+---------------------+--------------+ | 114 | 1 | 2007-02-05 00:00:00 | 2000.00 | | 115 | 2 | 2007-02-05 00:00:00 | 2100.00 | | 118 | 3 | 2007-02-05 00:00:00 | 10500002.00 | | 126 | 2 | 2007-02-07 00:00:00 | 20000.00 | +-------------+------------+---------------------+--------------+ mysql> select * from max_donations; +------------+-------------+ | contact_id | donation_id | +------------+-------------+ | 1 | 114 | | 3 | 118 | | 2 | 126 | +------------+-------------+ Thanks very much in advance Winn Johnston ____________________________________________________________________________________ The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]