473,399 Members | 3,401 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,399 software developers and data experts.

Filtering resultsets based on GROUP_CONCAT() generated value

$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 ORDER BY upper(e.ethnicity_name))), " .
' GROUP_CONCAT(e.ethnicity_name ORDER BY
upper(e.ethnicity_name))' .
" ) AS ethnicity_name \n\n";

This segment of a larger SQL query produces a string that normally
looks like these:

caucasians

caucasians,african-americans

caucasians,african-americans,asian-americans

Nordic peoples,caucasians

"etc"

Here's the problem. Requirement states that we now need to filter the
results by "ethnicity", which is a one-to-many relationship per
applicant.

Let's say you have 20 applicants, and out of those, 1 of those has just
"caucasians" for ethnicity.

When you do the filter which I envision as:

WHERE ... AND ethnicity_name LIKE '%caucasians%'

Instead of having this value in the $result[$i]->ethnicity_name field
resultset value:

caucasians

You see this:

caucasians,caucasians,caucasians,caucasians,caucas ians..[repeated 7
times]

Take out the filter and it displays just fine.

I am not sure how much more info I can provide; the query itself is
about 200 lines long and is under U.S. Government regulated security
(illegal to post it, sorry), unfortunately this is all I can think of
that is allowable to post that illustrates the problem.

Should note there there is an "ethnicity" table with 7 rows in it with
unique ethnicity names like "caucasians", "african-americans", etc.,
and a field in the "applicant" table that is
"applicant_ethnicity_interest_other" where you can enter whatever
ethnicity you want on top of the selected ethnicities in the
"ethnicity" table - if that helps.

Thanx
Phil

Apr 28 '06 #1
0 1212

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

Similar topics

1
by: peter stickney | last post by:
I am using the GROUP_CONCAT() as follows: SELECT (SELECT CONCAT(ProjectName) FROM Project WHERE FIND_IN_SET(ProjectID, RelatedProjectID))AS RelatedProject We have a project tracker system and...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
1
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
0
by: Romulo NF | last post by:
Greetings again everyone Recently i´ve been asked to develop a script to allow filtering in the content of the table, with dinamic options based on the own content. Example: a table with the name of...
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: 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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.