这是一个有效的SQLite查询

时间:2012-11-29 05:07:38

标签: java android mysql sql sqlite

我有:

String sqlite = "SELECT count(_id) AS _lCount FROM answers WHERE phase = 3 and correct_incorrect='1'    

作为查询,但我需要correct_incorrect列才能考虑“1 *”

这是解决问题的有效方法吗?

String sqlite = "SELECT count(_id) AS _lCount FROM answers WHERE phase = 3 and correct_incorrect='1'or'1*'

我会测试它,但是“1 *”的可能性很少,需要几个小时的测试。所以我想确保我不只是在浪费时间。

3 个答案:

答案 0 :(得分:6)

使用IN

尝试
String sqlite = "SELECT count(_id) AS _lCount FROM answers WHERE phase = 3 and correct_incorrect IN ('1','1*')"

答案 1 :(得分:2)

据我所知,它应该是这样的:

String sqlite = "SELECT count(_id) AS _lCount FROM answers WHERE phase = 3 and (correct_incorrect='1' or correct_incorrect = '1*')

答案 2 :(得分:1)

这里给出了很多查询,但我认为'1'会出现'1 *'

String sqlite = "SELECT count(_id) AS _lCount FROM answers WHERE phase = 3 and correct_incorrect like '1*'";

这个查询怎么样?