Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8584771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:51:02+00:00 2026-06-11T21:51:02+00:00

Ok I am trying to construct a query that will give me results a-z

  • 0

Ok I am trying to construct a query that will give me results a-z and group them within there primary category. Each result should give me about 30 or more listings per category. However with this query.

select teamName, CONCAT(UCASE(leagueType)) as league
from fmr_teamNames 
group by leagueType 
order by teamName asc

I will only get a single listing per category. Which I understand to a point cause I am using a group by condition.

When I reorder the query a little and remove the group by condition I get all my listings but they are in z-a. When the desired goal is categories a-z then the inner results per category a-z

select teamName, CONCAT(UCASE(leagueType)) as league
from fmr_teamNames
order by leagueType asc

This currently gives me a-z on the categories, and z-a on the results per. So I am a little confused as to how to better form this query for my results, without having to use some outside intervention like PHP to reorder everything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:51:03+00:00Added an answer on June 11, 2026 at 9:51 pm

    I think you are mistaking the concat function for the group_concat function in mysql. Concat will append two strings together, while group_concat will merge rows together.

    select teamName, group_concat(UCASE(leagueType)) as league
    from fmr_teamNames 
    group by teamName 
    order by teamName asc
    

    Your query also seemed to use a group by on the aggregated column rather than the unique one you are trying to identify?

    Example:

    mysql> select * from table1;
    +---------+------+------+-------------+
    | autonum | ID   | name | metavalue   |
    +---------+------+------+-------------+
    |       1 |    1 | Rose | Drinker     |
    |       2 |    1 | Rose | Nice Person |
    |       3 |    1 | Rose | Runner      |
    |       4 |    2 | Gary | Player      |
    |       5 |    2 | Gary | Funny       |
    |       6 |    2 | Gary | NULL        |
    |       7 |    2 | Gary | Smelly      |
    +---------+------+------+-------------+
    7 rows in set (0.00 sec)
    
    mysql> select concat(autonum, ID) from table1 group by ID;
    +---------------------+
    | concat(autonum, ID) |
    +---------------------+
    | 11                  |
    | 42                  |
    +---------------------+
    2 rows in set (0.00 sec)
    
    mysql> select group_concat(autonum, ID) from table1 group by ID;
    +---------------------------+
    | group_concat(autonum, ID) |
    +---------------------------+
    | 11,21,31                  |
    | 42,52,62,72               |
    +---------------------------+
    2 rows in set (0.01 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to construct a JDOQL query (using datanucleus) that will search for matches
I am trying to construct a MySQL query that will allow me to pull
I am trying to construct a LINQ query that will take a list of
I'm trying to construct a query that will include a column indicating whether or
I'm trying to construct a query that will allow me to pull a person
I'm trying to construct a MySQL query that will UPDATE a row in my
I'm trying to construct a MySQL query that will only return unassigned tasks. A
I'm trying to construct a query that will map two columns, one, a date
I'm trying to construct a datatype that is essentially a binary tree whose: each
I'm trying to construct XQuery that will return the count of the number attributes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.