SQL Commands Flashcards
What is SQL?
It is a declarative language used for creating, querying and updating tables in a relational database.
What is the SELECT keyword used for?
Used to extract a collection of fields from a given table.
Show the syntax of the SELECT command:
SELECT ,
FROM ,
WHERE
ORDER BY
The default for ORDER BY is ascending.
Example:
SELECT CDTitle, RecordCompany
FROM CD
WHERE DatePublished = 01/01/2015
ORDER BY CDTitle
What are the most common ‘standard conditions’ that can be used with SQL?
=, <=, >=, !=, AND, OR etc.
What does the IN condition mean?
Equal to a value within a set of values.
What does the LIKE condition mean?
Similar to.
What does the BETWEEN…AND condition mean?
Within a range, including the two defining values.
What does the IS NULL condition mean?
Field doesn’t contain a value. eg CD IS NULL
What does NOT do?
Invert truth.
What is the ORDER BY keyword used for?
Gives control over how the results are displayed.
How would you further sort data using the ORDER BY keyword?
Give the command another parameter to sort by. eg SORT BY Name, Date.
How would you use the SELECT command to extract and combine data from multiple tables?
Use the SELECT command as usual but prefix the field name with the table name: tablename.fieldname
eg SELECT Song.SongTitle, Artist.ArtistName
What does the JOIN command do?
JOIN combines rows from tables based on common fields between them.
What is the CREATE TABLE keyword used for?
Used to create a new SQL table.
Show the syntax of the CREATE TABLE command:
CREATE TABLE
(
)