Skip to content

Inner join between three tables fails #290

Discussion options

You must be logged in to vote

its clear from the exception thrown that column Name exist in table - labels & categories and that's why query can not be completed.

just rename column name using as option similar to how you are doing for id.

the below query should work -

var results = await connection.select({
    from: "transactions",
    join:[{
        with:"labels",
        on: "transactions.label=labels.id",
        as: {
            id: "labelsId",
            name:"labelsName"
        }
    },{
        with:"categories",
        on: "labels.category=categories.id",
        as: {
            id: "catId",
            name:'catName'
        }
    }]
});
console.log(results);

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by femto-code
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #289 on September 23, 2022 14:47.