本文介紹了如何使用IN子句查詢ApacheIgnite的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在ApacheIgnite中創建了一個架構,如下所示:
---------------------------------------------
EmpId | EmpName | HomeZip | OfficeZip| Dept |
---------------------------------------------
1 | Sam | 98123 | 98123 | A |
---------------------------------------------
2 | Jack | 98123 | 98123 | B |
---------------------------------------------
3 | John | 98124 | 98123 | A |
---------------------------------------------
4 | Kim | 98124 | 98123 | C |
---------------------------------------------
如何執行以下查詢:
查找A部門員工的所有詳細信息
查找其home Zip與OfficeZip相同的員工的所有詳細信息。
如何使用SQLQuery執行此操作并將響應映射到Model類
class Employee{
private Integer empId;
private String empName;
private String homeZip;
private String officeZip;
private String dept;
}
我嘗試按如下方式查詢,但出現錯誤:
//For finding out employee in list of departments
SqlQuery sql = new SqlQuery(Employee.class, "dept in (?)).setArgs(deptList);
//For finding out employee with same zip for office and home:
SqlQuery sql = new SqlQuery(Employee.class, "homeZip = officeZip");
推薦答案
跟隨鏈接:https://apacheignite-sql.readme.io/docs/performance-and-debugging#sql-performance-and-usability-considerations
SqlFieldsQuery sql = new SqlFieldsQuery(
"select e.* from Employee e join table(dept varchar = ?) d on e.dept = d.dept")
.setArgs(new Object[]{deptList.toArray()});
這篇關于如何使用IN子句查詢ApacheIgnite的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,