I am currently working with a JSON object that represents two companies, Ebay and Amazon.
For the Ebay Object:
{
__v: 0
_id: "56e192f0aea7131c15513328"
headquarters: "New York"
name: "Ebay"
productCategories: [{
_id: "56e193beaea7131c1551332d"
name: "Footwear"
products: [{
name: 'Shiela',
price: 420,
totalSales: [10, 20]
}, {
name: 'Parry',
price: 350,
totalSales: [50, 20]
}]
totalSales: 100
}, {
1: Object
_id: "56e193beaea7131c1551332e"
name: "Clothes"
products: [{
name: 'Kurta',
price: 210,
totalSales: [60, 80]
}, {
name: 'Sun Glass',
price: 785,
totalSales: [5, 25]
}],
totalSales: 170
}]
}
And for the Amazon Object:
{
__v: 0
_id: "56e192f0aea7131c15513328"
headquarters: "New York"
name: "Amazon"
productCategories: [{
_id: "56e193beaea7131c1551332d"
name: "Footwear"
products: [{
name: 'Shiela',
price: 280,
totalSales: [10, 20]
}, {
name: 'Parry',
price: 785,
totalSales: [50, 20]
}]
totalSales: 100
}, {
1: Object
_id: "56e193beaea7131c1551332e"
name: "Clothes"
products: [{
name: 'Kurta',
price: 150,
totalSales: [60, 80]
}, {
name: 'Sun Glass',
price: 485,
totalSales: [5, 25]
}],
totalSales: 170
}]
}
I aim to compare and extract common product names and prices between both companies based on their shared product categories.
While attempting to do so, I encountered an error when running a specific query. Here is the code snippet:
alasql('SELECT products.name,products.price FROM ? as category1 join ? as category2 using products.name', [$scope.company1.productcategories,$scope.company2.productcategories], function(data) {
console.log("Query executed");
console.log(data);
});
I believe there might be a mistake in the query execution method. Any guidance on how to correctly achieve this comparison would be greatly appreciated.
Best Regards, Sabarisri