我對的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