Basic SQL Statement Definitions Flashcards

1
Q

What does SQL stand for?

A

Structured Query Language

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

SELECT

A

The SELECT statement is used to select data from a database.

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

SELECT DISTINCT

A

The SELECT DISTINCT statement is used to return only distinct (different) values.

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

WHERE

A

The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.

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

AND

A

The AND operator displays a record if all the conditions separated by AND are TRUE.

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

OR

A

The OR operator displays a record if any of the conditions separated by OR is TRUE.

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

NOT

A

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

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

ORDER BY

A

The ORDER BY keyword is used to sort the result-set in ascending or descending order. The ORDER BY keyword sorts the records in ascending order by default.

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

DESC

A

Used with the ORDER BY keyword to sort the records in descending order.

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

INSERT INTO

A

The INSERT INTO statement is used to insert new records in a table.

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

NULL

A

A field with a NULL value is a field with no value.

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

UPDATE

A

The UPDATE statement is used to modify the existing records in a table.

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

DELETE

A

The DELETE statement is used to delete existing records in a table.

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

SELECT TOP

A

The SELECT TOP clause is used to specify the number of records to return.

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

MAX()

A

The MAX() function returns the largest value of the selected column.

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

MIN()

A

The MIN() function returns the smallest value of the selected column.

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

COUNT()

A

The COUNT() function returns the number of rows that matches a specified criterion.

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

AVG()

A

The AVG() function returns the average value of a numeric column.

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

SUM()

A

The SUM() function returns the total sum of a numeric column.

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

LIKE

A

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

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

What are 2 wildcards often used in conjunction with the LIKE operator?

A

The percent sign (%) represents zero, one, or multiple characters.

The underscore sign (_) represents one, single character.

22
Q

Wildcard: *

A

Represents zero or more characters.

23
Q

Wildcard: ?

A

Represents a single character.

24
Q

Wildcard: []

A

Represents any single character within the brackets. Used with brackets [].

25
Q

Wildcard: !

A

Represents any character not in the brackets. Used with brackets [].

26
Q

Wildcard: -

A

Represents any single character within the specified range. Used with brackets [].

27
Q

Wildcard: #

A

Represents any single numeric character.

28
Q

Wildcard: %

A

Represents zero or more characters.

29
Q

Wildcard: _

A

Represents a single character.

30
Q

Wildcard: ^

A

Represents any character not in the brackets.

31
Q

IN

A

The IN operator allows you to specify multiple values in a WHERE clause.

32
Q

BETWEEN

A

The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates.

33
Q

AS

A

Stands for Aliases. Aliases are used to give a table, or a column in a table, a temporary name.

34
Q

JOINS

A

A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

35
Q

INNER JOIN

A

The INNER JOIN keyword selects records that have matching values in both tables.

36
Q

LEFT JOIN

A

The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side, if there is no match.

37
Q

RIGHT JOIN

A

The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records from the left table (table1). The result is 0 records from the left side, if there is no match.

38
Q

FULL JOIN (FULL OUTER JOIN)

A

The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right (table2) table records.

39
Q

SELF JOIN

A

A self join is a regular join, but the table is joined with itself.

40
Q

UNION

A

The UNION operator is used to combine the result-set of two or more SELECT statements.

41
Q

GROUP BY

A

The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”.

42
Q

HAVING

A

The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate functions.

43
Q

EXISTS

A

The EXISTS operator is used to test for the existence of any record in a subquery.

44
Q

ANY

A

Allow you to perform a comparison between a single column value and a range of other values.

ANY means that the condition will be true if the operation is true for any of the values in the range.

45
Q

ALL

A

Allow you to perform a comparison between a single column value and a range of other values.

ALL means that the condition will be true only if the operation is true for all values in the range.

46
Q

SELECT INTO

A

The SELECT INTO statement copies data from one table into a new table.

47
Q

INSERT INTO SELECT

A

The INSERT INTO SELECT statement copies data from one table and inserts it into another table.

48
Q

CASE

A

The CASE expression goes through conditions and returns a value when the first condition is met (like an if-then-else statement). So, once a condition is true, it will stop reading and return the result. If no conditions are true, it returns the value in the ELSE clause.

If there is no ELSE part and no conditions are true, it returns NULL.

49
Q

ISNULL()

A

The SQL Server ISNULL() function lets you return an alternative value when an expression is NULL.

50
Q

Stored Procedure

A

A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again.

So if you have an SQL query that you write over and over again, save it as a stored procedure, and then just call it to execute it.

You can also pass parameters to a stored procedure, so that the stored procedure can act based on the parameter value(s) that is passed.