MySQL Select multiple rows and return each value as array value <p>In order to make my code a bit cleaner, I want the db to return a compact result. I managed to get the result with some "array tickling", but I'm pretty sure it is not "state of the art".... I tried UNION / GROUP_CONCAT .. but apparently not the right way!</p> <p>Could you me help me out please?</p> <p>Many thanks in advance!</p> <p>PS: and no ... I'm not building some kind of online dating site.. :P</p> <p>Table:</p> <pre><code>id user_id field_id value ------------------------------------ 48 929 28 Blablabla 27 937 4 Sex, Drugs, Rock´n Roll 9 934 4 OMG_TRUMP 39 929 26 Normal 50 929 30 Normal </code></pre> <p>My query:</p> <pre><code>SELECT value, field_id FROM '.$db-&gt;quoteName('#__community_fields_values').' WHERE user_id = '. $my-&gt;id . ' AND field_id IN (34,33,36) </code></pre> <p>Result:</p> <pre><code>Array ( [0] =&gt; Array ( [value] =&gt; 24 [field_id] =&gt; 33 ) [1] =&gt; Array ( [value] =&gt; COM_COMMUNITY_FEMALE [field_id] =&gt; 34 ) [2] =&gt; Array ( [value] =&gt; 61 [field_id] =&gt; 36 ) ) </code></pre> <p>What I would like to get:</p> <pre><code>Array ( [33] =&gt; 24 [34] =&gt; COM_COMMUNITY_FEMALE [36] =&gt; 61 ) </code></pre>