473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Summarizing a column to a DISTINCT value

Hey folks,
I am just getting into MySQL and have run into a problem with
subqueries.
I am running MySQL 4.0.21 and I am trying to CONCAT and I have no idea
where I'm tripping up...

The data looks like this....

+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue |
| 2 | mixer | green |
| 3 | mixer | yellow |
+----+------------+

I need to generate this....
+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue/green/yellow |
+----+------------+

In short, for each distinct product, generate a color field where the
all the choices are concatenated by a slash.

My apologies if this is remarkably simple. The real world query is
actually more brutal than this one which I have reduced for simplicity.

Sherabg

Sep 9 '06 #1
1 2483

wo**********@gmail.com wrote:
Hey folks,
I am just getting into MySQL and have run into a problem with
subqueries.
I am running MySQL 4.0.21 and I am trying to CONCAT and I have no idea
where I'm tripping up...

The data looks like this....

+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue |
| 2 | mixer | green |
| 3 | mixer | yellow |
+----+------------+

I need to generate this....
+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue/green/yellow |
+----+------------+

In short, for each distinct product, generate a color field where the
all the choices are concatenated by a slash.

My apologies if this is remarkably simple. The real world query is
actually more brutal than this one which I have reduced for simplicity.

Sherabg
So what does your query for this hypothetical problem look like?

Sep 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Caleb | last post by:
I'm using the following query to look in a log file and show some statistics. It counts the total number of views and the total number of unique users who have viewed a particular item (the "id"...
4
by: wendy | last post by:
Just curious to know if there is a simple way to ensure uniqueness among non-null values within a nullable column. For instance if I have a column of Names that can contain null values, I would...
17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
12
by: yoyo | last post by:
So I'm trying to make an application that currently works with MySql, Postgre, etc... work with DB2. THe problem I have, is, the varchar column only goes to 32k. CLOB goes bigger, but at a major...
4
by: sheraz1 | last post by:
Hi, I am new to VBA, I am trying to create a form that will take the DISTINCT values of a one column and then display all the records associated to that value in the form. I am not sure...
0
by: rajesh | last post by:
Hi , i want to select the first minimum date in the column d for each distinct column a value. how i can do that in a sql query. xyztable Column a Column b Column c ...
4
by: omnittha | last post by:
I would like to pull unique records of a SINGLE column but not the other related columns. When I use DISTINCT, it pulls up all the records which are unique across the columns. Here is the code.......
1
watertraveller
by: watertraveller | last post by:
Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.