I want to assign values to null cells of a column as
UPDATE table 1 SET number = MAX(number) + 1 WHERE number IS NULL
but mysql return error
Invalid use of group function.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
Assuming that you want - if the
max(number) in the whole table is say, 27 - to update all the rows with NULL, to 28.
You need a subquery or a derived table to first find this max and then join back to the table:
UPDATE tableX AS t CROSS JOIN ( SELECT MAX(number) AS max_number FROM tableX ) AS m SET t.number = m.max_number + 1 WHERE t.number IS NULL ;