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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:42:34+00:00 2026-06-11T07:42:34+00:00

I am currently querying a MySQL database for data and getting results back in

  • 0

I am currently querying a MySQL database for data and getting results back in PHP.

I am running the query

SELECT title.id, title.title, title.description
FROM co_titles title
WHERE title.id = :title

And I am getting the result back as follows:

Array ( 
    [0] => Array ( 
        [id] => 1966 
        [title] => Example Title 
        [description] => Example Description
    )
)       

There is nothing wrong with the query and this is the exact result I expect, however I would like my result to look like this:

Array (
    [1966] => Array (
        [title] => Example Title 
        [description] => Example Description
    )
)   

SEE EDIT BELOW, this is no longer relevant: Is there a way I can modify my query in order to make the output look like this? I want to do this without using PHP, only MySQL, unless this is completely impossible in MySQL!

I thank you all very much for your help, I have been banging my head against a wall on this one.

EDIT: Okay it seems that basically what I was trying to do was impossible. Could someone assist with the most efficient way of converting from one to the other?

Okay I figured it out, for anyone after me, the best way I found was as follows:

function parseNotes($notes)
{
    $returnarray = array();
    foreach($notes as $i)
    {
        $returnarray[$i['id']] = $i;
        unset($returnarray[$i['id']]['id']);
    }
    return $returnarray;
}

Thank you all for your help!

  • 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-11T07:42:36+00:00Added an answer on June 11, 2026 at 7:42 am

    You can’t. The records returned by the query is linear. The only way to do that is by formating it in your PHP code. MySQL is a server a has no capability to do that even if you use GROUP BY.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've around 1GB of structured text data, (which is currently stored in database MySQL,
I'm currently trying to fetch data with JQPL. My Query looks like SELECT NEW
I currently use mysql_real_escape_string to escape a variable when querying the database to prevent
I have a problem querying multiple tables in MySQL and am currently at my
PLATFORM: PHP, mySQL & jQuery WHAT I HAVE: I have a Database table. Within
I'm currently saving some Twitter data in MySQL. My host only lets me run
I currently use enums as TINYINTs in MySQL database. My tables have a few
I got a problem in querying an information in mySQL, here's the code: SELECT
Querying by HQL with select a from Article a join a.tags t where t.name
I use EntityFramework, I'm querying and returning partial data using Anonymous Types. Currently I'm

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.