我有以下表格列
public static final String SHOWID = "show_id";
public static final String SHOWNAME = "show_name";
public static final String SHOWSEASON = "season_name";
public static final String EPISODENAME = "episode_name";
public static final String EPISODESTATUS = "episode_status";
我想进行以下查询
SELECT episode_name , episode_status FROM tv_show WHERE show_name='aName' AND season_name='aSeason'";
怎么做?
我不想使用db.rawQuery(...)
我想用这样的东西
db.query(
true,
DBTABLE,
new String[] {SHOWSEASON},
SHOWNAME + " like ?",
new String[] { String.valueOf(shName) },
null, null, null, null
);
答案 0 :(得分:1)
这是基本的SQL,快速搜索,您可以找到解决方案:
SELECT episode_name , episode_status FROM tv_show WHERE show_name='aName' AND season_name='aSeason'";
您必须使用AND
,而不是&
您可以执行类似的操作,并在需要时将'='替换为'LIKE':
Cursor cursor = db.query(TVSHOW_TABLE, new String[] { EPOSIDENAME, EPISODESTATUS }, SHOWNAME + "='" + aName + "' AND " + SEASONNAME + "='" + aSeason + "'", null, null, null, null);