?
Solved

MySQL; update on two tables

Posted on 2014-11-12
4
Medium Priority
?
166 Views
Last Modified: 2014-11-12
I need to replace the c.EXTRA_ID in the ccode table with the e.EXTRA_ID in the extra table.

extra
+----------------------------------------------
| EXTRA_ID | JOB_ID | JobID      | ExtraID    |
|  1000953 |  55418 | 12-15-0001 | 801        |

ccode
+------------------------------------------------------------------
| CCODE_ID | JOB_ID | EXTRA_ID | SCCODE_ID | JobID      | ExtraID |
|   803064 |  55418 |   680999 |        36 | 12-15-0001 | 801     |

UPDATE ccode c, extra e
SET c.EXTRA_ID = e.EXTRA_ID
WHERE e.JOB_ID = c.JOB_ID  AND e.ExtraID = c.ExtraID AND c.EXTRA_ID = 1000954;

When I run it it say it was successful, but it doesn't update c.EXTRA_ID

Query: update ccode c, extra e set c.EXTRA_ID = e.EXTRA_ID where e.JOB_ID = c.JOB_ID and e.ExtraID = c.ExtraID and c.EXTRA_ID = 1000953

0 row(s) affected
0
Comment
Question by:hdcowboyaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 2000 total points
ID: 40438819
Try this :

update ccode c, extra e set c.EXTRA_ID = e.EXTRA_ID where e.JOB_ID = c.JOB_ID and e.ExtraID = c.ExtraID and e.EXTRA_ID = 1000953

Open in new window


I assume the Extra_id is from Extra table so you miss typed the table synonim
0
 

Author Comment

by:hdcowboyaz
ID: 40438820
never mind, brain freeze. should be

UPDATE ccode c, extra e
 SET c.EXTRA_ID = e.EXTRA_ID
 WHERE e.JOB_ID = c.JOB_ID  AND e.ExtraID = c.ExtraID AND e.EXTRA_ID = 1000954;
0
 

Author Closing Comment

by:hdcowboyaz
ID: 40438822
Yes, thaniks
0
 

Expert Comment

by:Vsevolod Geraskin
ID: 40438823
replace c.EXTRA_ID = 1000954; with e.EXTRA_ID = 1000954; ?
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question