1 | initial version |
You can use the following SQL query to update multiple rows in a MySQL column from another table randomly:
UPDATE table1
SET column1 = (
SELECT column2
FROM table2
ORDER BY RAND()
LIMIT 1
);
In this query, table1
is the table in which you want to update the data, column1
is the column you want to update, and table2
is the table from which you want to select the data randomly.
The ORDER BY RAND()
clause is used to sort the data in table2
randomly, and the LIMIT 1
clause is used to select only one row from table2
.
Note: It's important to ensure that both tables have a common key that can be used to match the rows.