I have a json object like below.
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
}]
}
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 want to select each name inside product categories, that are common to both the companies.
Then, I want to select the products that are common to the common product categories.
Then I want to get the price of the common products (to both the companies) for comparison
I am able to run the below query
alasql('SELECT products FROM ? AS CATEGORY1 JOIN ? AS CATEGORY2 USING [0]', [$scope.company1.productCategories, $scope.company2.productCategories], function(data) {
console.log("join query executed");
console.log(data);
});
I want to find the products inside each product category. I want a query like
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);
});
But this errors out.
Please let me know the correct procedure.
Regards, Sabarisri