Basic SQL Syntax Flashcards

Learn the syntax of basic SQL commands.

1
Q

ALTER TABLE

A

ALTER TABLE table_name

ADD column_name datatype;

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

AND

A
SELECT column_name(s)
FROM table_name
WHERE column_1 = value_1
  AND column_2 = value_2;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

AS

A

SELECT column_name AS ‘Alias’

FROM table_name;

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

AVG()

A
SELECT AVG(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

BETWEEN

A

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value_1 AND value_2;

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

CASE

A
SELECT column_name,
  CASE
    WHEN condition THEN 'Result_1'
    WHEN condition THEN 'Result_2'
    ELSE 'Result_3'
  END
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

COUNT()

A
SELECT COUNT(column_name)
FROM table_name;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

CREATE TABLE

A
CREATE TABLE table_name (
  column_1 datatype, 
  column_2 datatype, 
  column_3 datatype
);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

DELETE

A

DELETE FROM table_name

WHERE some_column = some_value;

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

GROUP BY

A

SELECT column_name, COUNT(*)
FROM table_name
GROUP BY column_name;

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

HAVING

A

SELECT column_name, COUNT()
FROM table_name
GROUP BY column_name
HAVING COUNT(
) > value;

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

INNER JOIN

A

SELECT column_name(s)
FROM table_1
JOIN table_2
ON table_1.column_name = table_2.column_name;

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

INSERT

A

INSERT INTO table_name (column_1, column_2, column_3)

VALUES (value_1, ‘value_2’, value_3);

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

IS NULL and IS NOT NULL

A

SELECT column_name(s)
FROM table_name
WHERE column_name IS NULL;

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

LIKE

A

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;

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

LIMIT

A

SELECT column_name(s)
FROM table_name
LIMIT number;

17
Q

MAX()

A
SELECT MAX(column_name)
FROM table_name;
18
Q

MIN()

A
SELECT MIN(column_name)
FROM table_name;
19
Q

OR

A

SELECT column_name
FROM table_name
WHERE column_name = value_1
OR column_name = value_2;

20
Q

ORDER BY

A

SELECT column_name
FROM table_name
ORDER BY column_name ASC | DESC;

21
Q

OUTER JOIN

A

SELECT column_name(s)
FROM table_1
LEFT JOIN table_2
ON table_1.column_name = table_2.column_name;

22
Q

ROUND()

A
SELECT ROUND(column_name, integer)
FROM table_name;
23
Q

SELECT

A

SELECT column_name

FROM table_name;

24
Q

SELECT DISTINCT

A

SELECT DISTINCT column_name

FROM table_name;

25
Q

SUM()

A
SELECT SUM(column_name)
FROM table_name;
26
Q

UPDATE

A

UPDATE table_name
SET some_column = some_value
WHERE some_column = some_value;

27
Q

WHERE

A

SELECT column_name(s)
FROM table_name
WHERE column_name operator value;

28
Q

WITH

A
WITH temporary_name AS (
   SELECT *
   FROM table_name)
SELECT *
FROM temporary_name
WHERE column_name operator value;