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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.