Helenp
Helenp

Reputation: 143

Mysql, update table between day-month any year

I have a table with all days for 10 years in rows (one row per day).

I need to update all rows between a date set, lets say for example from 4th april until 10th June, and for all years in the table.

How can I do it without doing an update for each year? This is the query:

     $query = $dbh->prepare("UPDATE table
     SET price_client=:price_client
     WHERE date between '04-04' and '06-10");

Upvotes: 0

Views: 88

Answers (1)

chirag satapara
chirag satapara

Reputation: 1937

I just change the date format to %m-%d and compare it with your value.

Try below query:

 $query = $dbh->prepare("UPDATE table
 SET price_client=:price_client
 WHERE DATE_FORMAT(date,'%m-%d') between '04-04' and '06-10'");

Upvotes: 3

Related Questions