-1

I have a contract table in my database and those contracts have a start date and an end date. How can I change their active state if the current date is after the end date?

I already figured out that I'll do it with a stored procedure that gets executed every day or something like that. My Problem is, I don't know, how I can check each row in the table. It seems like something extremely basic yet I can't think of any solution.

I found this Response and it looks very promising but I'm afraid I don't understand the way it's supposed to work.

I'd highly appreciate any and all pointers.

EDIT: I found the solution and my way of approaching the problem was way off.

1 Answers1

0

Thanks to @RiggsFolly I found the solution:

UPDATE contract_conclusion SET is_active=0 WHERE CURDATE() > date_end_contract_conclusion;
  • While this may solve your problem, it certainly doesn't satisfy the question posed in the title. – Strawberry Oct 09 '19 at 09:11
  • 1
    @Strawberry Why not? It just means that I approached the problem completely wrong, more from a PHP-Coder point of view without considering the database-oriented approach. So now I managed to solve it the way a problem like this is supposed to be solved, and not in the way I originally intended to. – Christian Gröber Oct 09 '19 at 09:17