W3. SQL Not Flashcards

1
Q

Q: What does the SQL NOT operator do?

A

A: It returns the opposite or negative result of a specified condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q: Write a query to select all customers that are NOT from Spain.

A
SELECT * FROM Customers 
WHERE NOT Country = 'Spain';
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Q: What is the general syntax for using the NOT operator?

A

SELECT column1, column2, …
FROM table_name
WHERE NOT condition;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q: How would you write a query to select customers whose names do not start with “A”?

A
SELECT * FROM Customers 
WHERE CustomerName NOT LIKE 'A%';
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q: Write a query to select customers with CustomerID not between 10 and 60.

A
SELECT * FROM Customers 
WHERE CustomerID NOT BETWEEN 10 AND 60;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q: How do you use NOT with the IN operator to exclude certain values?

A

A: Use NOT IN, e.g., WHERE City NOT IN (‘Paris’, ‘London’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q: Write a query to select customers who are not from Paris or London.

A
SELECT * FROM Customers 
WHERE City NOT IN ('Paris', 'London');
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q: How do you select customers with a CustomerID not greater than 50?

A
SELECT * FROM Customers 
WHERE NOT CustomerID > 50;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Q: Is there an alternative syntax for “not greater than”?

A

A: Yes, !> can be used as a “not greater than” operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Q: How do you select customers with a CustomerID not less than 50?

A
SELECT * FROM Customers 
WHERE NOT CustomerID < 50;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Q: Is there an alternative syntax for “not less than”?

A

A: Yes, !< can be used as a “not less than” operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly