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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:43:56+00:00 2026-06-01T11:43:56+00:00

I have a table with lots of different columns, like resolution, brightness, type, width,

  • 0

I have a table with lots of different columns, like

resolution, brightness, type, width, camera_type, projection_type etc 

I need to get the names of only those columns, that are relevant to, say LED tv’s to build filters, – which means I need to somehow

SHOW COLUMNS FROM Goods WHERE category_id = 5 AND [there is at least one value in the column for a row that meets the category_id = 5 condition]

Is it even possible?

  • 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-01T11:43:58+00:00Added an answer on June 1, 2026 at 11:43 am

    I’m guessing what you want is the column names that have a non-null value where category_id = 5. The difficulty here is finding out which columns have a non-null value where category_id = 5. This will have to be accomplished on a per column basis but can be done.

    To be honest… I don’t work in MySql but I’m certain you can follow along and make any adjustments needed.

    -- create a temp table to hold the results
    CREATE TEMPORARY TABLE TempTable (columnName varchar(100));  
    
    -- create a bunch of dynamic SQL to insert its name into the temp table when category_id = 5 and its value is not null
    
    DECLARE column_name VARCHAR(100);
    
    DECLARE no_more_rows BOOLEAN;
    DECLARE loop_cntr INT DEFAULT 0;
    DECLARE num_rows INT DEFAULT 0;
    
    -- Declare the cursor
    DECLARE columns_cur CURSOR FOR
      SELECT
          column_name
      FROM information_schema.columns
      WHERE TABLE_NAME = 'Goods';
    
    -- Declare 'handlers' for exceptions
    DECLARE CONTINUE HANDLER FOR NOT FOUND
      SET no_more_rows = TRUE;
    
    OPEN columns_cur;
      select FOUND_ROWS() into num_rows;
    
    the_loop: LOOP
    
      FETCH  columns_cur 
      INTO   column_name;
    
      IF no_more_rows THEN
          CLOSE columns_cur;
          LEAVE the_loop;
      END IF;
    
      PREPARE stmt FROM 'IF(EXISTS(SELECT * FROM Goods WHERE ? IS NOT NULL AND catetory_id = 5)) INSERT INTO TempTable (column_name) VALUES ('?');'
    
      EXECUTE stmt USING @column_name;
      DEALLOCATE PREPARE stmt;
    
    END LOOP the_loop;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly complicated html table containing lots of PHP, CSS etc., and
I have a MySQL table with just a single text type column with lots
I have a table with lots of generic link from a DB. Now the
I have a MySQL table holding lots of records that i want to give
I have a htlm table with lots of data the user might want to
I'm working on a project that will have a single table holding lots and
I have a repeater with a table in it with lots of properties of
Lets say I have a really big table filled with lots of data (say,
I am building a data warehouse. I need to get data from different sources
I have this table: create table demo ( key number(10) not null, type varchar2(3)

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.