![](/img/trans.png)
[英]How to restrict user by entering data for specific month where records greater than secific month exists in Yii2
[英]How to get records greater than selected year and month when the year is greater and month is less than specified one in Yii2
我正在使用 Yii2 基本版。 我有一個名為 groupsavingdetails 的表。 在那個表中,我有一個特定組的記錄,ID 為 29,從 2017 年開始,8 月、9 月、10 月、11 月和 12 月。 2018 年 1 月和 3 月也有同一組的記錄。
情況是我想更新年份為 2017 年,月份為 9 月的記錄。 現在我想獲得大於 2017 年 9 月記錄的所有記錄。 我應該得到總共 5 條記錄,但以下查詢只提取了 3 條記錄。
SELECT * FROM groupsavingdetails WHERE groupsavingdetails.GroupId=29 and Year>=2017 and Month>9
下面是包含記錄的表的圖像。 所以我應該從 Id 47,48,49,51,52 獲取記錄。 我該怎么拿到。
SELECT * FROM groupsavingdetails WHERE
groupsavingdetails.GroupId=29
and ( Year > 2017 or (Year>=2017 and Month > 9) )
在此查詢中
如果年份大於 2017 它將顯示
並且年份是 2017 並且月份大於 9 也顯示
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.