2

Possible Duplicate:
Merge two rows in SQL

I have the following values in table:

---------------------
row1 | row2 | row3
---------------------
val1 |      |
     | val2 | 
     |      | val3

How do I merge these rows?

$qu = mysql_query("SELECT * FROM `table`");

while($row = msyql_fetch_assoc($qu)){
$rowone = $row['row1'];
$rowtwo = $row['row2'];
$rowtre = $row['row3'];

echo $rowone." ".$rowtwo." ".$rowtre;
}

I want this to return

val1 val2 val3

I have a theory about how this is possible but I was wondering if there is a more straightforward method.

Community
  • 1
  • 1
faq
  • 2,965
  • 5
  • 27
  • 35

2 Answers2

2

use an aggregate function on all columns.

SELECT MAX(row1), MAX(row2), MAX(row3)
FROM tableName
John Woo
  • 258,903
  • 69
  • 498
  • 492
0
SELECT concat(col1,col2,col3) as colname
FROM tableName
Vikram Jain
  • 5,498
  • 1
  • 19
  • 31