0

I have the following table column

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";

I want to do the following query

SELECT episode_name , episode_status FROM tv_show WHERE show_name='aName' AND season_name='aSeason'";

How to do this??

I don't want to use db.rawQuery(...)

I want to use something like this

db.query(
                true,
                DBTABLE,
                new String[] {SHOWSEASON}, 
                SHOWNAME + " like ?",
                new String[] { String.valueOf(shName) },
                null, null, null, null
                );
4

1 回答 1

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);
于 2013-05-09T13:59:52.373 回答