This can be a follow-up question to my previous one.
Situation:

Table 1:
+--------------------+--------------------+
|               v_id |             v_name |
+--------------------+--------------------+
|                  1 |            v_name1 |
+--------------------+--------------------+
| etc...

Table 2:
+--------------------+--------------------+
|               a_id |             a_name |
+--------------------+--------------------+
|                  1 |            a_name1 |
+--------------------+--------------------+
| etc...

Table 3:
+--------------------+--------------------+
|               v_id |               a_id |
+--------------------+--------------------+
|                  1 |                  1 |
+--------------------+--------------------+
|                  1 |                  2 |
+--------------------+--------------------+
|                  1 |                  3 |
+--------------------+--------------------+

I wish to obtain a join of these two tables:

SELECT t1.*, t2.a_name
FROM `table1` t1
LEFT JOIN `table_3` t3 ON t3.v_id = t1.v_id
LEFT JOIN `table_2` t2 ON t2.a_id = t3.a_id
WHERE t1.id = 1;

Caused by this question is going to be 3 rows for that given tables, each row with similar values from Table 1, only a different a_name from Table 3.
Now, is it feasible that i can make a_name an assortment (of three cells within this situation)? I believe that no chance. When not, wouldso would I must build the query to ensure that it might return only one row, using the a_name results became a member of having a given 'glue' string?


EDIT Basically were to obtain a lead to PHP, I'd expect something similar to:

$result = array(
    'v_id'    => 1,
    'a_name'  => array('a_name1', 'a_name2', 'a_name3')
);

or

$result = array(
    'v_id'    => 1,
    'a_name'  =>'a_name1, a_name2, a_name3'), # assuming I used ', ' as the glue string
);

Use:

    SELECT t1.*, 
           GROUP_CONCAT(DISTINCT t2.a_name SEPARATOR ',')
     FROM `table1` t1
LEFT JOIN `table_3` t3 ON t3.v_id = t1.v_id
LEFT JOIN `table_2` t2 ON t2.a_id = t3.a_id
   WHERE t1.id = 1
 GROUP BY [list of t1 columns here]

Sean Viera's answer works while you stated due to the WHERE clause, and since MySQL allows for columns to be omitted from the [cde]. It's a bad habit - only MySQL enables this, and the like queries won't port with other databases (there are many good examples on SO).

I added the distinct within the GROUP BY - did not think you would like replicates if any exist.

In my opinion you're searching for the [cde] function.

Inside your query it might seem like this:

GROUP_CONCAT