Hello guys I don't get it.
I have two tables
1, null, null, user1, user2
1, 2, 1, user1, user2
SELECT @curUsername := user.username, @curUserid := user.id FROM user;
UPDATE post SET post.fromid = @curUserid WHERE post.sender = @curUsername;
When you want to write any expression that combines columns from more than one row, you can use a join.
UPDATE Posts JOIN User AS FromUser ON Posts.sender = FromUser.username JOIN User AS ToUser ON Posts.receiver = ToUser.username SET Posts.fromid = FromUser.id, Posts.toid = ToUser.id;
MySQL supports joins in an
UPDATE statement (although this is not part of standard SQL).