I have 2 tables and I need to UPDATE
the value of table1
for uid = 0
.
Here my tables:
table1: games
id | uid |
--------+---------+
1 | 5 |
2 | 7 |
3 | 0 |
table2: users
idu | name |
--------+---------+
1 | todd |
2 | mario |
3 | luigi |
So basically I need to UPDATE
the uid
value of the 3rd row of table1
with a random number between 1-3 (idu
values of table2
).
For the purpose I tried this:
UPDATE games (uid)
SET idu = ORDER BY rand() LIMIT 1 FROM users
WHERE uid = 0;
Why it's not working?