Skip to content

trouble building a query with multiple JOINs #15

@pfrazee

Description

@pfrazee

Hey Brian, got another one for you

I'm trying to do a many-to-many join, so I need 2 join statements. From what I can tell, it's not currently possible:

var query = utils.selectAsMap(products, req.fields)
  .from(products
    .join(productsProductCategories)
      .on(productsProductCategories.productId.equals(products.id))
    .join(productCategories) // fail
      .on(productCategories.id.equals(productsProductCategories.productCategoryId))
    )
  .where(products.id.equals(req.param('productId')))
  .toQuery();

The problem is that on doesn't continue the chain.

🍺

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions