'How to add a value in all NULL rows in a column in phpmyadmin
In my database, there is a column expiry date that has expire date of users' accounts, but some users have NULL value in expiry date due to an earlier bug. So I want to change expiry date of all rows in that column, but do not want to make change to rows that has expiry date added already. How can I accomplish that?
Solution 1:[1]
To test for NULL values, use the IS NULL and IS NOT NULL.
You did not provided more details about your table so I will give you generic example:
To find NULL values use WHERE expiry IS NULL aka
SELECT * FROM thetablename WHERE expiry IS NULL;
To update the NULL values use the same logic as above aka:
UPDATE thetablename SET expiry = '2022-01-01' WHERE expiry IS NULL;
Always do the
SELECTstatement with the same condition inWHEREpart to see what records will be impacted with theUPDATEstatement.
To name at least two references about working with NULL values are mariadb.com and dev.mysql.com.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ino |
