Closed femto-code closed 2 years ago
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);
Oh, sure, you're right - I didn't see that and just focused on the id column. Thanks!
I have three tables (transactions, labels, categories) that I would need to join for data acquisition. I use the following code:
All three tables have the column id which is why I set the as property on both. But stillt - this does not work and gives error:
{message: 'column name exist in both table labels & categories', type: 'invalid_join_query'}
Apart from giving them individual id column names: what can I do about it? Thanks.