Lets say that i have 2 tables: 1st has following columns:
products
--------
id name price
1 someproduct 99
2nd
productimages
-----------
productId img
1 someimgurl
1 someimgurl2
I would like to get name,price and images of product 1.
SELECT products.name, products.price, productimages.img FROM products INNER JOIN productimages WHERE products.id=1
This query gives me following result:
[ {
name: 'someproduct',
price: 99,
img:
'someimg' },
{
name: 'someproduct',
price: 99,
img:
'someimgurl2' }
]
As you see name and price are repeated.What i am trying to get as result is this:
[ {
name: 'someproduct',
price: 99,
img:[
'someimgurl','someimgurl2'] },
]