[英]Sqlite3, created View from more than 3 tables with WHERE Clause doesn't return results in android?
我已經使用此代碼在sqlite3 + android中創建了一個視圖;
CREATE VIEW IF NOT EXISTS viewProductList AS
SELECT p.product_id,c.category_name,s.subcategory_name,pt.type_size
FROM tCategory c,tproduct p,tproducttype pt,tsubcategory s WHERE (p.cat_id =c._id)
AND (p.product_type_id=pt.producttype_id)AND(pt.subcategory_id=s.sub_id)GROUP
BY p.product_id
但是在使用以下查詢android中的視圖時:
Cursor c = db.rawQuery("SELECT * FROM viewProductList ", null);
它不返回結果嗎?
您是否嘗試過直接針對視圖進行聲明? 它返回任何值嗎? 您確定視圖已創建嗎?
您的視圖語句不帶括號可能是一個問題嗎? 我會這樣寫:
CREATE VIEW IF NOT EXISTS viewProductList AS (
SELECT p.product_id,c.category_name,s.subcategory_name,pt.type_size
FROM tCategory c,tproduct p,tproducttype pt,tsubcategory s WHERE (p.cat_id =c._id)
AND (p.product_type_id=pt.producttype_id)AND(pt.subcategory_id=s.sub_id)GROUP
BY p.product_id)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.