I am working on MYSQL database and I am running into an issue. I have a column with dates on it. However, I am trying to set the whole column to null only if the entire date column is already filled with data.
What I have tried:
update users set date = null where date is not null
But, when I do this it's resetting the current date. How do I set the date to null only if the entire data column is filled with data?
For example I have a Random Name selector Program that selects a random user.
My table looks like this:
ID Name Date
1 A
2 B
3 C
When I select a Random User today:
ID Name Date
1 A
2 B
3 C 2016-03-12
My code is working fine for this scenario. I want keep the date for C and then select someone randomly tomorrow. If I run my code tomorrow it will only select between A and B and will put a date next to their name. For Example lets say it selected B then my table will look like:
ID Name Date
1 A
2 B 2016-03-13
3 C 2016-03-12
And on Monday my program has no choice but to select person A and my table will look like:
ID Name Date 1 A 2016-03-14 2 B 2016-03-13 3 C 2016-03-12
So far my program is working fine. What I want is on Tuesday(03/15/2016) when I go to run my random selector I want it to reset the dates for B and C to be set to Null and leave A with 2016-03-14 so that A doesn't get selected on Tuesday.