Is this table's select statement a valid one? (SQL)

Is this table's select statement a valid one? (SQL)
0

#1
CREATE TABLE clothing(id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,color TEXT,size INTEGER,price INTEGER,sex INTEGER);

INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 1", "white", 15, 20, 1);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 2","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 3","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 4","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 5","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 6", "white", 15, 20, 1);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 7","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 8","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 9","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 10","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 11", "white", 15, 20, 1);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 12","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 13","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 14","black",20,22,0);
INSERT INTO clothing (name,color,size,price,sex) VALUES("shirt 15","black",20,22,0);


SELECT * FROM clothing WHERE color = "black";

#2

What is the SQL engine you are working? You get any error?

Most SQL engines uses single quote for string literals 'black' instead of "black", same about your insert commands.

"black" means object/identifier named black, while 'black' means string literal black (not sure if all SQL engines come with this way)

Also this is better you use "name" instead of name. Some SQL engines raise error becasue name could be a keyword, same about size. referencing objects/identifiers using "" is recommended. Note "NAME" could be case-sensitive becasue of ""

You can also do one insert to insert all data which is recommended over multiple insert commands.


#3

I see… I just got into SQL and haven’t learnt that much. I will keep those info in mind.


#4

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.