开发者

How to use rawQuery() in android

开发者 https://www.devze.com 2022-12-09 02:50 出处:网络
I have a sql query like this String loadFav = \"SELECT _id, title, name, favorite FROM table1 where favorite= 1 \"

I have a sql query like this

String loadFav = "SELECT _id, title, name, favorite FROM table1 where favorite= 1 " 
                     + "UNION ALL" 
                     + "SELECT _id, title, name, favorite FROM table2 where favorite= 1"
                     ;

    Cursor mCursor = mSQLiteDatabase.rawQuery(loadFav, null);

I got an error开发者_如何学C when run this query. Is it right structure? Can someone help me?


Always troubleshoot by looking at the SQL string -- not the code that builds the SQL string!

SELECT _id, title, name, favorite FROM table1 where favorite= 1 UNION ALLSELECT _id, title, name, favorite FROM table2 where favorite= 1

You need a space between ALL and the second SELECT.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号