English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My table look like this.
| Name |
| ---------|
| Sam |
| Scott |

I need Output like this:
Sam,Scott

What is the query to get this out put ( I am using MySQL)?

2007-03-22 18:29:36 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

This is your answer
set @names := '';
select @names := concat(@names,yourfield,',') from yourtable where yourcondition;
select substr(@names,1, length(@names) -1);

2007-03-25 09:32:40 · answer #1 · answered by Mukhtar 1 · 0 0

You want multi-column output: Look at the tutorial link below:

2007-03-23 01:36:44 · answer #2 · answered by suavesoyyo 3 · 0 0

Try Using Procedures. . .

2007-03-23 01:33:48 · answer #3 · answered by imran 2 · 0 0

$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM person");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "
";
}
mysql_close($con);
?>

2007-03-23 01:47:18 · answer #4 · answered by Daniel B 2 · 0 0

fedest.com, questions and answers