Skip to content

Select from two table with distinc #1017

Answered by simolus3
rrifafauzikomara asked this question in Q&A
Discussion options

You must be logged in to vote

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)));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rrifafauzikomara
Comment options

Answer selected by rrifafauzikomara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants