I have following two tables (here with random data)
cu cgm
+-----+---------+-----+ +---------+--------+
| uid | name | ... | | groupid | userid |
+-----+---------+-----+ +---------+--------+
| 1 | manfred | ... | | 2 | 2 |
| 2 | peter | ... | | 2 | 5 |
| 3 | jackson | ... | | 2 | 7 |
| ... | ... | ... | | 4 | 3 |
+-----+---------+-----+ +---------+--------+
uid <========= FOREIGN KEY ========== userid
I want to select cu.name and cu.uid / cgm.userid by cgm.groupid and put the values into an associative array where the keys are cu.name and the values cu.uid / cgm.userid. My only solution was to send a query to select cgm.userid by cgm.groupid, send a second query to select cu.name by cu.uid and put the data together. But I was wondering, if there is way to achieve this with only one query and use PHP as less as possible.