Situation: I am using wordpress and I have 60000 old posts. Now I have to update each posts with some new information. For some reason, I have to compare the custom fields in SQL and find the same post id. Then make the changes.
SQL struction:
table1(t1): wpxf_posts column name1(c1): ID column name2(c2): post_name
table2(t2): wpxf_postmeta column name3(c3): post_id column name4(c4): code
What I have to do:
Here is a picture to help to describe
I read some posts but most of them teach us how to compare the difference. I am not sure if they suit my case as it seems did not find the same value. This one may be helpful but I don't know how to apply to my situation. SQL Replace used during a compare
Try using a case statement:
Update table2
Set c4 = Case When c1 = c2 Then c2 Else c4 End
From table2
Join table1
On (What ever column you should join on)
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.