Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Perform the following query using Greendao ?

I have 2 tables A and B.

Table A contains names and table B contains selected names.

Now I would like to perform the following query on these tables using greendao, Please let me know if it is possible and if it is not are there any alternatives (maybe a raw query).

select * 
from A inner join B
on A.nameid = B.nameid

Also, Table A columns: id, nameid, name
and Table B columns: id, nameid, name, rating

like image 674
Rushi Avatar asked Dec 16 '22 01:12

Rushi


1 Answers

I think this might help. You can use the raw query as a fake join. And you get all you want in the Query object

Query query = ATableDao.queryBuilder().where(
new StringCondition("nameid IN " +
"(SELECT nameid FROM B_Table )").build();

Since "nameid" doesn't seems to be a unique identifier in your sample. I won't suggest to use Relations to solve this issue. If you are try to use Relations, you can find my previous answer here.

like image 198
Nevin Chen Avatar answered Jan 01 '23 04:01

Nevin Chen