SQLite在同一列中的多个位置

时间:2016-03-02 21:00:20

标签: android sqlite where-clause

我有一张这样的表:

Char1       Char2       Difficulty
--------------------------------------------------
jon          sara          1
pablo        victor        2
laura        patricia      1
marta        juanjo        3
marina       goku          4

我想选择难度为1且难度为2的所有行。我试过这样做:

"SELECT * FROM " + table + " WHERE " + DatabaseOpenHelper.COLUMN_DIFFICULTY + " LIKE '1%'" + " AND " + DatabaseOpenHelper.COLUMN_DIFFICULTY + " LIKE '2%'" 

但它不起作用,我是SQLite的新手所以我会很感激答案的任何解释。谢谢!

1 个答案:

答案 0 :(得分:0)

存在多个问题:

  1. 你实际上没有描述你的问题,而且#34;它没有工作"。

  2. 您需要在列名和td关键字之间使用空格。

  3. 您根本不需要delete a from target_table a left JOIN (select max(id_field) as id, field_being_repeated from target_table GROUP BY field_being_repeated) b on a.field_being_repeated = b.field_being_repeated and a.id_field = b.id_field where b.id_field is null; 。使用LIKE代替LIKE

  4. 要合并多个条件,您可能需要=1代替LIKE '1%'。单行列不能同时为ORAND