The following query will return exactly as you requested: Joaquim, Sérgio, Ricardo, Maria, César, Rafael, Solange
$result = mysql_query("SELECT DISTINCT colA FROM SuaTabela UNION SELECT DISTINCT colB FROM SuaTabela UNION SELECT DISTINCT colC FROM SuaTabela");
while($row = mysql_fetch_array($result))
{
$nome=$row['colA'];
$array=$array.$nome.",";
}
//retira a última virgula do array
$array = substr($array,0,-1);
Considerations
The MySQL extension is deprecated, so the most ideal is to use mysqli or PDO.
As we all know, the default way to declare arrays in PHP is as follows:
$ names = array ('joaquim', 'Ricardo', 'Rafael');
As of PHP5.4, we have a new way of declaring arrays
$ names = ['joaquim', 'Ricardo', 'Rafael'];
Regardless of your question, there are several interpretations of the table and column names.
Depending on the names the querys can be:
SELECT DISTINCT col.A FROM col UNION SELECT DISTINCT col.B FROM col UNION SELECT DISTINCT col.C FROM col
or, which gives the same as above
SELECT DISTINCT A FROM col UNION SELECT DISTINCT B FROM col UNION SELECT DISTINCT C FROM col
Finally if the name of your columns have even a dot in the names then the names of the columns in the query must be enclosed in inverted commas:
$query = mysql_query("SELECT DISTINCT 'col.A' FROM stabela UNION SELECT DISTINCT 'col.B' FROM stabela UNION SELECT DISTINCT 'col.C' FROM stabela");
while($row = mysql_fetch_array($query))
{
$nome=$row['col.A'];
$array=$array.$nome.",";
}
$array = substr($array,0,-1);