473,396 Members | 2,013 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,396 software developers and data experts.

GROUP_CONCAT() produces fatal error in MySQL 4.1.12 - time-sensitive issue

SELECT s.id, s.student_first_name, s.student_last_name,
IF(s.student_ethnicity_interest_other IS NOT NULL AND
s.student_ethnicity_interest_other != '',
CONCAT(s.student_ethnicity_interest_other, ', ',
e.ethnicity_name),
GROUP_CONCAT(DISTINCT e.ethnicity_name ORDER BY
upper(e.ethnicity_name))
) AS ethnicity_name

FROM student s, ethnicity e, student_ethnicity_interest_assoc seia
WHERE s.id = seia.student_id
AND seia.ethnicity_id = e.id

GROUP BY s.id, s.student_first_name, s.student_last_name,
ethnicity_name
ORDER BY upper(ethnicity_name) ASC

This query produces the following error:

Can't group on 'ethnicity_name' using query: SELECT s.id...

I am trying to prevent this from happening:

ID student_first_name student_last_name ethnicity_name
1 Phil Powell
hispanics
1 Phil Powell
african-americans

I want this instead:

ID student_first_name student_last_name ethnicity_name
1 Phil Powell
hispanics,african-americans

Please help, this is time-sensitive as this is unfortunately live

Phil

Mar 3 '06 #1
2 1904
<ph**************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Can't group on 'ethnicity_name' using query: SELECT s.id...


First, you need to specify the table alias in the GROUP BY clause, or else
your usage of ethnicity_name is ambiguous:

GROUP BY s.id, s.student_first_name, s.student_last_name, e.ethnicity_name

Second, you need to remove ethnicity_name from your GROUP BY clause, or else
you it doesn't make sense to use it in the GROUP_CONCAT function. You'll
always get each value of the ethnicity on separate rows anyway. That's how
GROUP BY works.

GROUP BY s.id, s.student_first_name, s.student_last_name

Regards,
Bill K.
Mar 4 '06 #2

Bill Karwin wrote:
<ph**************@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Can't group on 'ethnicity_name' using query: SELECT s.id...
First, you need to specify the table alias in the GROUP BY clause, or else
your usage of ethnicity_name is ambiguous:

GROUP BY s.id, s.student_first_name, s.student_last_name, e.ethnicity_name

Second, you need to remove ethnicity_name from your GROUP BY clause, or else
you it doesn't make sense to use it in the GROUP_CONCAT function. You'll
always get each value of the ethnicity on separate rows anyway. That's how
GROUP BY works.

GROUP BY s.id, s.student_first_name, s.student_last_name


That did it! AT LAST!!!!!!!!! Now if only I understood what you did :(
Thanx!!

Phil

Regards,
Bill K.


Mar 4 '06 #3

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

Similar topics

1
by: BT | last post by:
Hi .. a newbie question. I get the following error: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/index.php on line 3. I have the following RPMS installed on RH7.2...
4
by: gc | last post by:
I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this before. I'm teaching myself PHP/MySQL and trying to setup a guestbook. I'm running latest versions of Apache, PHP and...
1
by: Mike | last post by:
Last weekend I decided to install Apache 2.0.53-win32-x86-no_ssl PHP 5.0.3 Smarty 2.6.7 MySQL essential-4.1.10-win32 I have Apache up (Port 80 blocked at the router and firewall!) and I have...
6
by: bettina | last post by:
I want to list all the countries (147 in total) per continent with the quantity of beercoasters that each country has. I get the following message: Fatal error: Maximum execution time of 30...
1
by: drewmania001 | last post by:
i've read various info on the web including the following http://php.mirrors.ilisys.com.au/manual/en/ref.mysqli.php mySQL Version 4.1.16 PHP Version 5.1.2 with Zend Engine v2.1.0 OS Windows...
2
by: phillip.s.powell | last post by:
Here are my results using MySQL 4.1.12 and I honestly don't think this is right, but can't figure out what to do: mysql> select id, group_concat(DISTINCT school_enrollment_time_name SEPARATOR...
0
by: phillip.s.powell | last post by:
$if1 = "IF(s.student_ethnicity_interest_other IS NOT NULL AND s.student_ethnicity_interest_other != '', " . " CONCAT(s.student_ethnicity_interest_other, ', ', GROUP_CONCAT(e.ethnicity_name...
0
by: gmorris | last post by:
I am attempting to pull data from multiple tables into a resultset that I can use as an Excel spreadsheet for reporting. Here is my query so far: SELECT b.bug_id,p.realname as 'Assigned'...
49
by: Julian Bowler | last post by:
Please can some one help with my problem; I am running Apache web server on my lap top, plus a mysql server and php. The version of php currently installed is 5.2.5. when i write some php to connect...
1
bilibytes
by: bilibytes | last post by:
Hi, I'm wondering how to achieve the following: well i don't know if you guys like wine but I have to explain a very little on wine to explain my example: Wine is made from grape and a wine...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.