SQL Flashcards

1
Q

How do you use the SELECT statement to extract a collection of fields from a table?

A

SELECT [field1, field2, etc.]
FROM [table]
WHERE [search criteria boolean statement]
ORDER [order to be displayed in, desc or asc]

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

How do you use the SELECT statement to extract a collection of fields from more than one table?

A

SELECT [record1.field, record2.field1, record2.field2]
FROM record1, record2
WHERE [search criteria boolean statement]
ORDER [order to be displayed in, desc or asc]

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

How do you use JOIN to combine rows from two or more tables based on a common field between them?

A

SELECT [record1.field, record2.field1, record2.field2]
FROM record1
JOIN record2
ON [e.g. record1.personID = record2.personID]
WHERE [search criteria]

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

How do you add a column/field to a table?

A

ALTER TABLE [table name]

ADD [field name] [data type e.g. VARCHAR(10)]

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

How do you modify a column/field in a table?

A

ALTER TABLE [table name]

MODIFY COLUMN [field name] [change e.g. VARCHAR(20)]

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

How do you delete a column/field from a table?

A

ALTER TABLE [table name]

DROP COLUMN [column name]

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

How do you modify a specific record in a table?

A

UPDATE [table name]
SET [column1 = value1, column2 = value2, etc]
WHERE columnX = valueX

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