Please follow basic Netiquette and post the DDL we need to answer this. Follow Industry and ANSI/ISO standards In your data. You should follow ISO-11179 rules for naming data elements.
We need to know the data types, keys and constraints on the table. Avoid dialect In favor of ANSI/ISO Standard SQL.
I have the below table
NO! This Is just a picture and very rude. We have to guess at the DDL you did not even try to post. Then we have to type It for you. We do not even have a valid table name!
Columns are not fields. This difference is covered in the first week of a good SQL class or any book.
have table called attributes.
NO! That term is meta data and we never mix data and meta-data in a table. Are you trying to write a NoSQL (attribute, value) pair database in SQL? This does not work. There is no such crap as a generic "id" in RDBMS; that is the kabbalah number from magic, not an identifier from logic.
Did you know that the UPC or EAN or GTIN bar codes have the brand and product names in them? You could normalize this schema. Here is my guess at repairs:
CREATE TABLE Products
(brand_name VARCHAR(20) NOT NULL,
product_name VARCHAR(20) NOT NULL,
sku CHAR (5) NOT NULL PRIMARY KEY,
warranty_duration INTEGER DEFAULT 0 NOT NULL
CHECK (warranty_duration >= 0)
In this table, I want to get the sku of those, whose value
are 60 Months and TV from the Name [sic] field [sic] <<
SELECT sku, brand_name, product_name, warranty_duration
WHERE warranty_duration >= 60
AND product_name = 'TV';
You do not have a complicated query; you have a bad design that makes all queries needlessly difficult.