简体   繁体   中英

Turn Update/Join into query

I have

Update2 `Table1` AS T1 Inner Join `Table2` As T2
On T2.`Name` = T1.Name
Set T1.`ParentID` = T2.`ID`

I want to check it first, getting brain freeze after long weekend, help appreciated.

I basically want to check first

Select FieldA, concat(FieldC,', ',FieldD) `Table1` AS T1 Inner Join `Table2` As T2
on T2.`Name` = T1.Name
Set T1.`ParentID` = T2.`ID`

to make sure I'm getting the right results.

An equivalent SELECT could be:

SELECT T1.`ParentID` = T2.`ID`
FROM `Table1` AS T1 Inner Join `Table2` AS T2
  ON T2.`Name` = T1.Name

pt-query-digest is an example of a tool that translates UPDATEs into SELECTs so it can run EXPLAIN.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM