Jump to content

Newbie SQL query help. select within select or nested select


yourguide

Recommended Posts

Hi all...  I have searched the forum, but I am either missing it or I don't understand enough to know how it applies to my situation so here goes.

 

I have one table, just one.

That table has product information in that includes spec data on each product.

the columns are like "specalum", "specwatt", "specfoo", "specbar", etc.

 

I want to return items that have spec data within ANY spec% column as long as that data is not empty like ''  or 'N'  since thats a flag meaning it doesn't apply to that product.

 

what I have so far is:

SELECT COLUMN_NAME FROM information_schema.`COLUMNS` C WHERE table_name = 'webitemmaster' AND COLUMN_NAME LIKE 'Spec%' ;

 

Which gives me a list of all the "Spec%" columns....  now I need to somehow search within each of those columns in the list for any value that is NOT '' or 'N' 

 

I am new to SQL, so please bear with me...  my table name is webitemmaster

Could some kind soul please point me in the right direction.  I think a select within a select is right, but I dont know exactly how to express it.

 

Thank you so much for your time.

Link to comment
Share on other sites

I realize this DB is not normalized.... but this is what I have to work with.

I am a consultant and this is a small project... I suppose I can tell them I need to rewrite the daily dump of data so that its in a normal form.... but they just want it done ASAP.

Thanks for your input.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.