SugarORM query from multiple tables?

泄露秘密 提交于 2019-12-05 18:21:19

SugarORM provides a Query Builder object for simple queries. Since it doesn't provide supporto for joins, you can directly execute a raw query and store the result into an object created ad-hoc.

So, build your custom raw query renaming the fields in the SELECT part

CustomOBJ.executeQuery("SELECT tableA.fieldA as field1, tableA.fieldB as field2, tableB.fieldA as field 3 FROM tableA JOIN tableB WHERE .....");

and then create your custom object

public CustomOBJ {
    private String field1;
    private String field2;  
    private String field3;

   public CustomOBJ(){} //you must declare an empty constructor

   //getters
   //setters
}

Here the documentation:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!