Select from two table with distinc #1017
Answered
by
simolus3
rrifafauzikomara
asked this question in
Q&A
-
I have query SQL like this:
How to write that query on moor? This is my table of LST_KURS:
This is my table of lst_prodset_calc:
This is my function in Dao:
|
Beta Was this translation helpful? Give feedback.
Answered by
simolus3
Jan 27, 2021
Replies: 1 comment 1 reply
-
If you want to load a full row with all columns from all tables, you could use final query = select(lstProductCalc, distinct: true).join(
[innerJoin(lstKurs, lstKurs.lkuId.equalsExp(lstProductCalc.lkuId))]);
query.where(lstProductCalc.psetId.equals(Variable(yourId))); If you're only interested in some columns, you could use final query = selectOnly(lstProductCalc, distinct: true)
..addColumns([lstKurs.lkuId, ...])
...join(
[innerJoin(lstKurs, lstKurs.lkuId.equalsExp(lstProductCalc.lkuId))]);
query.where(lstProductCalc.psetId.equals(Variable(yourId))); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rrifafauzikomara
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to load a full row with all columns from all tables, you could use
If you're only interested in some columns, you could use