How to extend this query for the entire table, to update all id
s?
UPDATE table1 SET number=(
SELECT COUNT(*) FROM table2 where id=1
) WHERE id=1
id
is the PRIMARY KEY
in table1 and FK
in table2.
How to remove the WHERE
clause to update each row of table1 by counting the number of rows in table2 with the same FK
id?