How to get records greater than selected year and month when the year is greater and month is less than specified one in Yii2


(Jamess) #1

Hi

I am using Yii2 basic. I have a table called groupsavingdetails. In that table I have records for a specific group with Id 29 and from year 2017 and Months August, September, October, November and December. Also there are records for the same group for year 2018 January and March.

The situation is I want to update record whose year is 2017 and month is September. Now I want to get all the records greater than September 2017 record. Total 5 records should I get but only 3 records are fetched by the following query.

SELECT * FROM groupsavingdetails WHERE groupsavingdetails.GroupId=29 and Year>=2017 and Month>9

Below is the image of table contaning records. So I should get records from Id 47,48,49,51,52. How should I get it.


(Softark) #2

Something like this?

WHERE groupsavingdetails.GroupId=29 AND ((Year=2017 and Month>9) OR (Year > 2017))