我在查询中使用了 LIKE 运算符
@Query("SELECT * FROM item where barcodes LIKE :barcode")
List<Item> getItemWithBarcode(String barcode);
有什么方法可以将某些内容(appendedTxt
) 添加到条形码?像这样
@Query("SELECT * FROM item where barcodes LIKE (:barcode + 'appendedTxt')")
List<Item> getItemWithBarcode(String barcode);
最佳答案
||运算符是“连接” - 它将其操作数的两个字符串连接在一起。 Docs
@Query("SELECT * FROM item where barcodes LIKE (:barcode || 'appendedTxt')")
List<Item> getItemWithBarcode(String barcode);
编辑:将双引号改为单引号
关于android - 如何在房间dao查询中连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52496281/