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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:54:18+00:00 2026-05-30T10:54:18+00:00

Is there a way to retrieve the column names of a query that returns

  • 0

Is there a way to retrieve the column names of a query that returns no data?

I’m using (somewhat) complicated queries such as:

SELECT 
    i.*,
    ic1.permalink as category_permalink, 
    ic1.title as category_title,
    ic1.sid as category_sid,
    ic2.permalink as hook_category_permalink,
    ic2.title as hook_category_title,
    ic2.sid as hook_category_sid
FROM item i
    LEFT JOIN item_to_item_category itic ON i.sid = itic.item_sid
    LEFT JOIN item_category ic1 ON ic1.sid = itic.item_category_sid
    LEFT JOIN item_category ic2 ON ic1.hook = ic2.sid
WHERE i.uid = ''
LIMIT 0,1 

The result of this query would be empty because of WHERE i.uid = "". Is there a way how to find the column names when there’s no result?

Please note that I’m aware of solutions using DESCRIBE and select column_name from information_schema.columns where table_name='person'; but I need a more flexible solution that will fit these multicolumn queries.

Please also note that I am still using the original PHP MySQL extention (so no MySQLi, and no PDO).

Anyone?

  • 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-30T10:54:19+00:00Added an answer on May 30, 2026 at 10:54 am

    For PDO, try PDOStatement->getColumnMeta(). For mysqli, there’s mysqli_result->fetch_fields(), mysqli_result->fetch_field() and mysqli_result->fetch_field_direct(). For mysql, replace it with PDO or mysqli.

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

Sidebar

Related Questions

Is there any way to retrieve the names of the stored procedures by some
Is there a way to retrieve the auto generated key from a DB query
I have the following query to retrieve a single column of data: routes_query =
Is there a way to query the database to retrieve information about the schema
Is there any way to retrieve a user's email address after authenticating with Yesod's
Is there a way to retrieve the parameters in the URL inside your HTML
Is there a way to retrieve first n elements from a Dictionary in C#?
is there a way to retrieve type T from IEnumerable<T> through reflection? e.g. i
Is there a way to retrieve path information from a file descriptor or FILE
Is there a way to retrieve wcf binding type and security mode just from

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.