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 6855243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:43:59+00:00 2026-05-27T01:43:59+00:00

I want to query a table in a mysql database and display the results

  • 0

I want to query a table in a mysql database and display the results in a list format like this:

A – G, H-p, Q-z

So all results with the first letter of their name starting with A to G will display under A – G and so on.

What is the best way to do this in php? can it all be done in the query itself? Or will I have to sort it in the php.

Got any examples of something similar?

  • 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-05-27T01:43:59+00:00Added an answer on May 27, 2026 at 1:43 am

    You can do it in SQL:

    SELECT * FROM table WHERE name < 'H';
    SELECT * FROM table WHERE name >= 'H' AND name < 'P';
    SELECT * FROM table WHERE name >= 'P';
    

    Or, in one query,

    SELECT *, 
        CASE 
            WHEN name < 'H' THEN 'A-G' 
            WHEN name >= 'H' AND name < 'P' THEN 'H-P' 
            ELSE 'Q-Z' 
        END AS category
    FROM table ORDER BY name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting teh results i want from this mysql query. And
I want to query the name of all columns of a table. I found
The Table - Query has 2 columns (functionId, depFunctionId) I want all values that
I want to use Access database with query for pivot table in Excel. How
I want to write a query to select from a table all rows with
I am doing a table join on a mysql databse. I want the results
I have a query to filter the result in mysql database into given letter
I have a mysql database with a table structure like below : Table Name
I want to query a table so that it´s ordered the following way: 1)
I have a query that does what i want joining table but i need

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.