解决方案 »

  1.   

    merge 可以实现你的功能,假设你products为T1表,等待处理的记录在T2表
    merge into t1 using t2 on(t1.pid=t2.pid)
    when matched then
    update set t1.min=(case when t1.price>t2.price then t1.min else t1.price end)
    when not matched then
    insert  values(t2.id,t2.pid,t2.price,t2.promotion,t2.min);
    PS:如果ID为自增的,可以将values中的T2.id换成的自增序列
      

  2.   

    直接用 insert ... on duplicte update 不就行了?ON DUPLICATE KEY UPDATE price = 88.88,promotion = concat(promotion,“满50减20”),min=if(88.88 <= price,88.88 ,min)