Say I have 2 tables:
Table 1
Name - Toys - broken
Jack    6      4
John    8      3
Mary    8      2
Nina    6      0

Table 2:
Name  -  ID
Mary     1
John     3
Jack     2
Nina     4

I need to merge Table 1 into table 2 and get the ID column to
match up with the persons name.
Notice the orders of both tables are different, and the only common field is the name

How do i do this?
Thank you.
UPDATE table1 t1 SET id = (SELECT id FROM table2 t2 WHERE t2.name = t1.name)

Id in Table1 must not be an auto increment column, and if it's a PK or UX it should be temporarily disabled.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.