[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

query in php

Posted on 2014-08-05
1
Medium Priority
?
275 Views
Last Modified: 2014-08-05
I have the following table

name    zone   site    location
rt              2         5         street1
rt              5         8         street29
ty              3         9         street3i
vt              1          1        street4
vt               5         1        street10

i want something like that
name    zone   site    location
rt              2,5         5,8         street1,street29
ty              3         9         street3i
vt              1,5          1,1        street4,street10

i am using php and mysql, how i can do a query from table 1 to produce the table2 ? Any idea?
0
Comment
Question by:joyacv2
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40242150
SELECT name, 
GROUP_CONCAT(zone SEPARATOR ', '),
GROUP_CONCAT(site SEPARATOR ', '),
GROUP_CONCAT(location SEPARATOR ', ') 
FROM table 
GROUP BY name

Open in new window

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question