SQL Flashcards

1
Q

select data from a database

A

SELECT

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

return only distinct (different) values

A

SELECT DISTINCT column1, column2, …

FROM table_name;

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

extract only those records that fulfill a specified condition

A

SELECT column1, column2, …
FROM table_name
WHERE condition;

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

Text Fields vs. Numeric Fields

A

SQL requires single quotes around text values

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

To specify multiple possible values for a column

A

IN
SELECT * FROM Customers
WHERE City IN (‘Paris’,’London’);

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

Search for a pattern

A

LIKE
SELECT * FROM Customers
WHERE City LIKE ‘s%’;

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

Between a certain range

A

BETWEEN
SELECT * FROM Products
WHERE Price BETWEEN 50 AND 60;

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

Not equal

A

<> or some version !=

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

operator displays a record if all the conditions separated

A

AND
SELECT column1, column2, …
FROM table_name
WHERE condition1 AND condition2 AND condition3 …;

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

operator displays a record if any of the conditions separated

A

OR
SELECT column1, column2, …
FROM table_name
WHERE condition1 OR condition2 OR condition3 …;

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

displays a record if the condition(s) is NOT TRUE

A

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

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

sorts the records in ascending order

A

ORDER BY ASC
SELECT column1, column2, …
FROM table_name
ORDER BY column1, column2, … ASC

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

sorts the records in descending order

A

ORDER BY DESC
SELECT column1, column2, …
FROM table_name
ORDER BY column1, column2, … DESC;

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

insert new records in a table

A

INSERT INTO
INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …);

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

a field with no value

A

NULL

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

Test for NULL Values

A
IS NULL Syntax
or IS NOT NULL
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
17
Q

modify the existing records in a table

A

UPDATE
UPDATE table_name
SET column1 = value1, column2 = value2, …
WHERE condition;

18
Q

delete existing records in a table

A

DELETE

DELETE FROM table_name WHERE condition;

19
Q

used to specify the number of records to return.

A

SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;