MySQL的从另外一张表update多个字段到另外一张表中去
例如: 把表 tk_zyt_scenery_order的 字段更新到 t_advs_order中去, 一般可能会这样写:
UPDATE t_advs_order SET
attribute1=(SELECT o.order_state FROM tk_zyt_scenery_order o WHERE o.order_id=`on`),
attribute2=(SELECT o.order_state FROM tk_zyt_scenery_order o WHERE o.order_id=`on`)
WHERE EXISTS (SELECT o.order_state FROM tk_zyt_scenery_order o WHERE o.order_id=`on`);
这样效率比较低下, 优化写法:
UPDATE t_advs_order a INNER JOIN tk_zyt_scenery_order s ON s.order_id=a.`on` SET
a.attribute1=s.order_id,
a.attribute2=s.order_id;
相关推荐
王艺强 2020-11-17
anchongnanzi 2020-09-21
84296033 2020-09-15
heimu 2020-08-02
herohope 2020-07-18
mrandy 2020-07-04
Jaystrong 2020-06-27
89921334 2020-06-26
debugjoker 2020-06-17
Linkaibin 2020-06-14
fanhuasijin 2020-06-14
Laxcus大数据技术 2020-06-13
hanshangzhi 2020-06-10
rainchxy 2020-06-07
Jerry 2020-06-01
lilygg 2020-05-29
lclcsmart 2020-05-27