使用另一个表中的值更新php MYSQL中的表

I am new to php, I am having trouble getting the right information in place, I am making a database of a social app, each user has their own user_id, I want a situation where as when they log in, and comment in the comments table the comment table grabs their user ID and puts it in the user_id of the comments table so that it is easy to identify which user commented, but all the queries I try wont work, can someone please help me?

If you want to update table from the other table, please check this out :

UPDATE pidato SET judul=(SELECT judul FROM artikel WHERE IDArtikel=39) WHERE IDPidato=1;

you can update judul column in table pidato from judul column in table artikel where IDArtikel is a 39;