Quantcast
Viewing latest article 35
Browse Latest Browse All 56

mySQL: Subquery to array?

I am working on a slight complex (at least for me) mySQL query containing a subquery and it isn't going to well to be honest.

SELECT `products`.`id`, `product`.`price`,   ( SELECT `value` FROM (`productValues`)     WHERE `productValues`.`product` = 'product.id'  ) as values FROM (`products`) WHERE`product`.`active` = 1

The current result looks like this:

Array(    [0] => Array        (            [id] => 1            [active] => 1            [price] => 1000            [values] =>         ))

What I want is the values element to also become an array with all elements in the Values table which matches (WHERE productValues.product = product.id).

What am I doing wrong?


Viewing latest article 35
Browse Latest Browse All 56

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>