CATEGORY TABLEには、事前に計算されたレコード数を別のテーブルPRODUCTSに格納するための3つの列があります。
CATEGORY(c_id,name,c30,c31,c32)
c30 =新製品のカウント(値30)c31使用済み製品のカウント(値31)c32損傷した製品のカウント(値32)
PRODUCT(p_id,c_id,name,condition)
条件は30、31または32にすることができます。
単一のUPDATEステートメントを作成することを考えているので、それぞれのカテゴリ数を更新します。
以下のステートメントは構文的に間違っていますが、私は同様のタイプの解決策を探しています。
select case product.condition
when 30 then update category set category.c30=category.c30+1 where category.c_id=product.category3
when 31 then update category set category.c31=category.c31+1 where category.c_id=product.category3
when 32 then update category set category.c32=category.c32+1 where category.c_id=product.category3
end case
from product
where product.c_id=12
なにか提案を!