mysql 多表联合更新

UPDATE mall_order mo
LEFT JOIN mall_order_goods mog ON mo.id = mog.order_id
SET mo.ratio=0.08
WHERE
mog.brand_id IN (409,417)

UPDATE mall_order mo
LEFT JOIN mall_order_goods mog ON mo.id = mog.order_id
SET mo.income=mog.income
WHERE
mog.income>0 and mo.income=0 and mo.goods_type=3 and

update mall_order set technical_charge = round_format(ratio*real_amount) where goods_type=3 and ratio>0 and technical_charge=0

select GROUP_CONCAT(id) as id,ratio from mall_brand group by ratio

SELECT
mo.id
FROM
mall_order mo
LEFT JOIN mall_order_goods mog ON mo.id = mog.order_id
WHERE
mog.brand_id IN (409,417)

多表联合删除

DELETE dotdee_uniform_settlement
FROM
dotdee_uniform_settlement
LEFT JOIN mall_order ON dotdee_uniform_settlement.orderid = mall_order.id
WHERE
mall_order.pay_status = 0
AND mall_order.`status` = 3
AND dotdee_uniform_settlement.settlement_status = 0

上一篇:解决运行nodejs代码Error: listen EADDRINUSE


下一篇:POJ 3276 Face The Right Way 反转