I am getting the 1111 error in the post title when executing the query below. Basically, I am try to update table 1 (special_valuation_temp) with data from table 2 (search_upload_quotes). I want to get the minimum and maximum quote values to update table 1 with.
UPDATE special_valuation_temp svt
INNER JOIN search_upload_quotes suq
ON ( svt.clei = suq.clei
OR svt.partnumber = suq.partnumber )
SET svt.vendor_low = ( Min(suq.priceperunit) * svt.qty ),
svt.vendor_high = ( Max(suq.priceperunit) * svt.qty )
WHERE suq.submitted = 1
AND suq.priceperunit > 0;
It seems that I can't use the MIN() and MAX() functions in the SET clause. Is there another way to do this?
Yes, that's incorrect without the use of
group by. You can rather get themin()andmax()value first in a subquery and perform ajoinwith that subquery result and do your calculation as-is.