Does ORMLITE support SQL EXISTS?

前端 未结 1 1607
借酒劲吻你
借酒劲吻你 2021-01-22 15:29

I am trying to query a table as follows

select * from client c
    where EXISTS (select * from visit v where c._id = v.client_id)

Can i do thi

相关标签:
1条回答
  • 2021-01-22 15:45

    Yes you can. Where.exists() has been supported my ORMLite for some time. Here are the [meager] docs:

    http://ormlite.com/docs/exists

    You would do something like the following:

    QueryBuilder<Visit, Integer> visitQb = visitDao.queryBuilder();
    visitQb.where().eq(Visit.CLIENT_ID_FIELD, client.getId());
    QueryBuilder<Client, Integer> clientQb = clientDao.queryBuilder();
    clientQb.where().exists(visitQb);
    List<Client> results = clientQb.query();
    
    0 讨论(0)
提交回复
热议问题