如何比较数据库字段的值

时间:2013-03-11 10:49:36

标签: android sqlite

我有一个dd.mm.yyyy格式的字符串日期值。我在数据库中有两列。两者都包含文本值。此值为dd.mm.yyyy格式的日期。我想比较我的字符串日期值与这些。并希望检查它是否介于这些之间。如果我的值大于第一个字段并且小于秒,则我想获取数据然后获取一些数据。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可以查看可以找出解决方案的示例代码(Sqlite-PhoneGAp)

不要将tx.ExecuteSQL()与PhoneGAp

混淆
 if(sType=='select' && sMode=='select'){

                     //SELECT * from Em_Expense where strftime('%m', expdate)='06' and strftime('%Y', expdate)='2011'

                     tx.executeSql('SELECT expenseType,expdate,description,price,mode from Em_Expense where strftime(\'%m\', expdate)="'+sMonth+'" and strftime(\'%Y\', expdate)="'+sYear+'"', [],queryCustomSearchSuccess, errorCB);
                 }
                 else if(sMode=='select' && sType!='select')
                     {

                     tx.executeSql('SELECT expenseType,expdate,description,price,mode from Em_Expense where strftime(\'%m\', expdate)="'+sMonth+'" and strftime(\'%Y\', expdate)="'+sYear+'" and expenseType="'+ sType +'"', [],queryCustomSearchSuccess, errorCB);
                     }
                 else if(sType=='select' && sMode !='select')
                     {

                     tx.executeSql('SELECT expenseType,expdate,description,price,mode from Em_Expense where strftime(\'%m\', expdate)="'+sMonth+'" and strftime(\'%Y\', expdate)="'+sYear+'" and mode="'+ sMode +'"', [],queryCustomSearchSuccess, errorCB);
                     }
                 else
                     {
                     tx.executeSql('SELECT expenseType,expdate,description,price,mode from Em_Expense where strftime(\'%m\', expdate)="'+sMonth+'" and strftime(\'%Y\', expdate)="'+sYear+'" and mode="'+ sMode +'" and expenseType="'+sType+'"', [],queryCustomSearchSuccess, errorCB);
                     }