简体   繁体   中英

How to set an int parameter in sugar orm findwithquery method to retreive data from sqlite database

Guys I want to set an int parameter to the findwithquery method in sugar orm to retrieve data from sqlite database in android. This is the query

List<cart> c=cart.findWithQuery(cart.class,
"Select * from cart where customer=? and status=?",1,"NOTPAID")

*the customer field is a integer field in the database

When I execute the above I get syntax error near "status"

Try this for hardcoded customer field 1

List<cart> c=cart.findWithQuery(cart.class,
"Select * from cart where customer=" + 1 + " and status=?", "NOTPAID");

For dynamic customer field

List<cart> c=cart.findWithQuery(cart.class,
"Select * from cart where customer=" + customerField + " and status=?", "NOTPAID");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM