Reputation: 639
I have two tables in MySQL, which named A and B.
I want to update B table u_id by selecting A table's u_id, with the condition a_id is equal to b_id.
For example, record in A looks like ('001', 'a00'),('003', 'a01'); record in B looks like ('001', ''), ('002', ''), ('003', '')
I want to update B table records with the result ('001', 'a00'), ('003', 'a01')
What is the fastest way to update the B table's u_id value? Thanks you.
Upvotes: 0
Views: 212
Reputation: 6112
Your query should look like this:
UPDATE tableB SET column2 = tableA.column2 WHERE tableB.column1 = tableA.column1
you can read up more on up update sql here.
Please let me know if you have any questions!
Upvotes: 1