android sqlite database error in using where clause in comparing things

时间:2017-09-30 06:51:51

标签: android sqlite

i am getting this error please help-

android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: SELECT SUM( amountinserted ) FROM mbudgettablewheredatename='30-09-2017'

CODE:

 Cursor cursor = db.rawQuery("SELECT SUM( " +amountinserted + " ) " +
            "FROM " +tablename + "where" +datename + "='" + rmethod() + "'", null);

3 个答案:

答案 0 :(得分:0)

在where子句周围使用空格+ " where "+

答案 1 :(得分:0)

您应该编写如下代码的代码:

Cursor cursor = db.rawQuery("SELECT SUM( " +amountinserted + " ) " + " FROM " +tablename + " **where** " +datename + "='" + rmethod() + "'", null);

在" FROM "之前您缺少空白区域。和" where "在查询中

答案 2 :(得分:0)

g = 'y'
while g == 'Y' or g == 'y':
speed = int(input('Enter mph: '))
time = int(input('Enter hours: '))

if time <= 0 or speed <= 0:
    print('Invalid Hours and mph must be greater than 0')
else:
    for t in range(time):
        distance = speed * (t+1)        // Use t+1 instead of time

        print(t + 1,':', distance)
        # time = time * 2              // No need to double the time


    g = 'n'
print('End')

Input: 
40
3

Output:
(1, ':', 40)
(2, ':', 80)
(3, ':', 120)
End

查询中的间距问题。请尝试此代码

相关问题