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

87 Views Asked by At

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"

1

There are 1 best solutions below

0
VVB On

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");