我对的SQLite数据库运行下面的查询。我知道至少在contact
表中有条目,尽管我没有得到任何结果。没有得到结果的SQLite查询
SELECT *
FROM contact,
phone,
email
WHERE cnt_cnt_id = phn_cnt_id
AND phn_cnt_id = eml_cnt_id
AND cnt_cnt_id = 1111
形成我的查询可以得到我想要加入这三个表的想法。 我应该怎么做才能从所有三个表中检索id为1111
的数据?
EDIT(表模式):
private static final String CONTACT_TABLE = "create table "
+ TABLE_NAME_CONTACT + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_CNT_CONTACT_ID + " text not null, "
+ COLUMN_CNT_FIRST_NAME + " text not null,"
+ COLUMN_CNT_LAST_NAME + " text not null,"
+ COLUMN_CNT_NICK_NAME + " text not null"
+ ");";
private static final String PHONE_TABLE = "create table "
+ TABLE_NAME_PHONE + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_PHN_CONTACT_ID + " text not null, "
+ COLUMN_PHN_NUMBER + " text not null"
+ ");";
private static final String EMAIL_TABLE = "create table "
+ TABLE_NAME_EMAIL + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_EML_CONTACT_ID + " text not null, "
+ COLUMN_EML_EMAIL_ID + " text not null"
+ ");";
添加表的模式。 – astuter
这3个表中存在什么值? – Mathew
@Mathew:用户名称暗示的细节。 – astuter