Unit 3 Database - Implementation - SQL SELECT Flashcards

1
Q

What is SQL used for?

A

SQL is used to add, display, change, or delete data from a database.

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

What does a SQL statement consist of?

A

A SQL statement consists of instructions to interact with a database.

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

What does the SELECT statement do?

A

The SELECT statement retrieves and displays data from a table based on specified conditions.

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

What is the syntax for the SELECT clause?

A

SELECT * | column1, column2, … FROM table1, table2, …

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

What does the wildcard ‘’ mean in SQL?

A

The wildcard ‘’ means selecting all columns from a table.

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

How do you retrieve specific columns from a table?

A

Specify the column names after the SELECT keyword, e.g., SELECT userid, accountname FROM user;

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

What does ORDER BY do in SQL?

A

ORDER BY sorts the query results in ascending (ASC) or descending (DESC) order.

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

How do you retrieve all data from a single table?

A

Use SELECT * FROM table_name;

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

How do you retrieve a single column from a table?

A

Use SELECT column_name FROM table_name;

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

How do you retrieve two columns from a table?

A

Use SELECT column1, column2 FROM table_name;

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

What is an equi-join in SQL?

A

An equi-join is a join that matches rows based on equality between a primary key and a foreign key.

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

How do you perform an equi-join between two tables?

A

Use SELECT * FROM table1, table2 WHERE table1.primary_key = table2.foreign_key;

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

How do you retrieve data from two tables with a specific condition?

A

Use SELECT * FROM table1, table2 WHERE table1.primary_key = table2.foreign_key AND condition;

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

How do you use the ‘AND’ operator in SQL?

A

Use AND to ensure multiple conditions are met, e.g., WHERE column1 = value1 AND column2 = value2;

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

How do you use the ‘OR’ operator in SQL?

A

Use OR to allow either condition to be met, e.g., WHERE column1 = value1 OR column2 = value2;

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

How do you use both ‘AND’ and ‘OR’ in SQL?

A

Use parentheses to group OR conditions with AND, e.g., WHERE column1 = value1 AND (column2 = value2 OR column3 = value3);

17
Q

How do you sort query results in descending order?

A

Use ORDER BY column_name DESC;

18
Q

How do you sort query results in ascending order?

A

Use ORDER BY column_name ASC;

19
Q

How do you retrieve specific rows based on multiple conditions?

A

Use WHERE with multiple conditions joined by AND or OR, e.g., WHERE column = value1 OR column = value2;

20
Q

How do you retrieve specific columns from two tables?

A

Use SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.primary_key = table2.foreign_key;

21
Q

How do you order query results by multiple columns?

A

Use ORDER BY column1 DESC, column2 ASC;

22
Q

How do you retrieve data for a specific client?

A

Use WHERE clientid = value;

23
Q

How do you order results by multiple conditions in SQL?

A

Use ORDER BY column1 sorting_order, column2 sorting_order;