网站建设知识
mysql连表更新 Mysql数据库导入的方法
2025-07-22 10:03  点击:2

mysql连表更新demo

update

member_base_info a

inner join

user_mapping b

on a.member_id=b.o2o_user_id

set a.card_no=b.real_card_no

where a.tenant_id=1055 and (a.card_no is null or a.card_no=”) and b.tenant_id=1055 and b.real_card_no is not null and b.real_card_no<>”;

需要注意的是:set 后面要更改的表不能是子查询,否则会报错”The target table a of the UPDATE is not updatable”

Mysql数据库导入的方法

mysql -u$USER -p$PASSWD --default-character-set=utf8 yourdb < db.table.sql

mysql -u$USER -p$PASSWD --default-character-set=utf8 yourdb < db.table.sql