There are two identical tables, let table1, table2, but one table is filled with data, and the second is only half. The tables have the following fields: id, user_id, youtube, ball.
In two tables, only the youtube field is filled in, in which the link to YouTube, i.e. The two tables contain user data: youtube, ball, the youtube field is already filled in the same two tables. This youtube field is like the key by which you now need to copy the ball field from table1 to table2.
The id, user_id fields differ in two tables; you cannot join tables with join.
In general, you need to do something like this query:
copy the field table1.ball to the field table2.ball, where table1.youtube = table2.youtube Tell me how to do this? if you send such a request:

SELECT * FROM `table1` t1 join `table2` t2 on t1.youtube=t2.youtube 

then, instead of the existing 30 lines, approximately 2000 lines will be returned. Of course, I know that you need to use update and probably nested select, but I haven’t yet figured out how to do it

  • This youtube field is like a key by which you need to copy . Is it at least unique? - Akina
  • @Akina yes, the youtube field is unique - word
  • (Especially) Then the phrase is incomprehensible instead of the existing 30 lines will return about 2000 lines - multiplying 2 tables with 30 records can not give more than 900 records ... - Akina

1 answer 1

All right, you need an update :

 update table2, table1 set table2.ball = table1.ball where table2.youtube = table1.youtube 

In the manuals everything is described in sufficient detail, at the end of the article is your case.