我有两个表,第一个表js_resume列为空,但第二个表 js_resume列中有数据
我想在js_resume为空时基于js_email进行比较,需要更新 来自第二张表的数据。
FIRST TABLE
+--------------------------------+-----------+
| js_email | js_resume |
+--------------------------------+-----------+
| panisam@hotmail.com | |
| rajchara-wee@hotmail.com | |
| jetnipit.s1992@gmail.com | |
| apitsada@hotmail.co.uk | |
| abcd@gmail.com | |
| junebb@hotmail.com | |
| settasak.songthummin@gmail.com | |
| james.oth@gmail.com | |
| balqisbinasli@gmail.com | |
| austinzmys@gmail.com | |
+--------------------------------+-----------+
Second table
+----------------------------+-------------------+
| js_email | js_resume |
+----------------------------+-------------------+
| panisam@hotmail.com | resume_59053.docx |
| rajchara-wee@hotmail.com | resume_59051.docx |
| ragavansamy@gmail.com | resume_59049.doc |
| rajchara-wee@hotmail.com | resume_59029.doc |
| narasimha67@gmail.com | resume_59047.doc |
| abcd@gmail.com | resume_59046.doc |
| azilin.aw@gmail.com | resume_59045.docx |
| lwy_51@yahoo.com | resume_59044.docx |
| limnc@singnet.com.sg | resume_59043.doc |
| austinzmys@gmail.com | resume_59042.docx |
+----------------------------+-------------------+
预期产量
+--------------------------------+----------------------------+
| js_email | js_resume |
+--------------------------------+----------------------------+
| panisam@hotmail.com | resume_59053.docx |
| rajchara-wee@hotmail.com | resume_59051.docx |
| jetnipit.s1992@gmail.com | |
| apitsada@hotmail.co.uk | |
| abcd@gmail.com | resume_59046.doc |
| junebb@hotmail.com | |
| settasak.songthummin@gmail.com | |
| james.oth@gmail.com | |
| balqisbinasli@gmail.com | |
| austinzmys@gmail.com | resume_59042.docx |
+--------------------------------+----------------------------+
答案 0 :(得分:1)
像这样吗?
UPDATE FIRSTTABLE a
JOIN Secondtable b ON a.js_email = b.js_email
SET a.js_resume = b.js_resume