# [EMAIL PROTECTED] / 2003-06-17 11:44:46 -0400: > At 05:14 PM 6/16/2003, Roman Neuhauser wrote: > ># [EMAIL PROTECTED] / 2003-06-16 15:15:31 -0400: > >> I can use: > >> > >> SELECT sum(if(voidreason>0,0,amt)) as sales FROM sdtik where acctno=1234 > >> and datein>=20020615 > >> > >> to gather customers' sales totals. How can I setup a single query where > >> the newdata.sales would be replaced with the summarized data from the > >> select. > > > > you need UPDATE or REPLACE, together with GROUP BY > > > > http://www.mysql.com/doc/en/REPLACE.html > > http://www.mysql.com/doc/en/UPDATE.html > > http://www.mysql.com/doc/en/SELECT.html
> > UPDATE sales, sdtik > > SET sales.sales = SUM(IF(voidreason > 0, 0, sdtik.amt)) > > WHERE sales.acctno = sdtik.acctno > > I tired both statements you suggested. The update is what I would like to > use, but I got an error, ERROR 1064: You have an error in your SQL syntax > near ' sdtik set sales.sales ....' you use a pre-4.0.4 MySQL, right? multi-table updates are supported since 4.0.4 (as stated in UPDATE.html). -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]