除了拼接原生 sql 語(yǔ)句余耽,也可以這樣拼接
//對(duì)輸入?yún)?shù)非空判斷進(jìn)行where拼寫
if (!TextUtils.isEmpty(cardId)) {
queryBuilder.where(PeopleDao.Properties.CardId.like("%" + cardId + "%"));
}
if (!TextUtils.isEmpty(nameStr)) {
queryBuilder.where(PeopleDao.Properties.Name.like("%" + nameStr + "%"));
}
if (!TextUtils.isEmpty(phoneStr)) {
queryBuilder.where(PeopleDao.Properties.Phone.like("%" + phoneStr + "%"));
}
queryBuilder.orderAsc(PeopleDao.Properties.CardId, PeopleDao.Properties.Name).build();
————————————————
版權(quán)聲明:本文為CSDN博主「倒騎驢走著瞧」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議泞莉,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明煌珊。
原文鏈接:https://blog.csdn.net/nongminkouhao/article/details/102843062