mysql 跨库查询修改
mysql 跨库连接查询,分同一个实例下和不同实例,同一实例下的不同库,可以直接写,不同实例暂时无法像oracle那样建立dblink后直接写语句。
库 cashier , urban_violation
表 table_name1 table_name2
SELECT
`cashier`.table_name1.id as cid,
`cashier`.table_name1.peccancy_id,`cashier`.table_name1.pay_status,
table_name2.id, table_name2.pay_fine_status
FROM
`urban_violation`.table_name2
LEFT JOIN `cashier`.table_name1 ON `cashier`.table_name1.peccancy_id = `urban_violation`.table_name2.id
WHERE
`cashier`.table_name1.pay_status = 2
UPDATE `cashier`.table_name1 AS a INNER JOIN `urban_violation`.table_name2 AS b ON a.peccancy_id=b.id
SET b.pay_fine_status = 1 where a.pay_status = 2