By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

Proper SQL String

P: 78
I'm a novice to mySQL. I am looking for help to develop a query that will add data to an existing tableA.

The query should check fieldA of tableA (also the PK)and check it against the fieldA (the same PK)in my dump. If they match, then my dump file would update fieldX, fieldY, and fieldZ on tableA from my dump fieldB, fieldC, fieldD.

If it is easier to do a column at a time that is acceptable.

How would you construct such a query?
Mar 27 '12 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,366
You would use an update query where you join the tables together on the PK.
Mar 27 '12 #2

Expert 100+
P: 1,035
more about the how to do the update is here, to join the tables you can find info here

after reading, and studying, you should get something like (intested)
Expand|Select|Wrap|Line Numbers
  1. UPDATE tableA A 
  2. INNER jOIN tableB B ON A.fieldA=B.fieldA 
  3.   SET A.fieldX=B.fieldB, 
  4.   A.fielY=B.fieldC, 
  5.   A.fieldZ=B.fieldD;
  6.  
Mar 27 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.