Basic Queries Flashcards
Learn the basic functions of queries
Queries
Allow us to communicate with the database by asking questions and having the result set return data relevant to the question.
SELECT
Is used every time you want to query data from a database.
FROM
Identifies the database schema from which data is being queried.
AS
Is a keyword in SQL that allows you to rename a column or table using an alias.
Distinct
When used will only return unique values. It filters out duplicate values.
WHERE
Is a restricting statement. filters the result set to only include rows where the following condition is true.
LIKE
is a special operator used with the WHERE clause to search for a specific pattern in a column. The pattern is up to the user to identify. Text conditions need ‘ ‘
%
is a wildcard character that matches zero or more missing letters in the pattern.
A%
matches all that with names that begin with letter ‘A’
%a
matches all that end with ‘a’
%a%
any value that contains the subject will return in the result.
BETWEEN
operator can be used in a WHERE clause to filter the result set within a certain range. The values can be numbers, text or dates.BETWEEN two letters is not inclusive of the 2nd letter.
BETWEEN two numbers is inclusive of the 2nd number.
AND
combines the two conditions. Used in conjunction with Where.
OR
operator displays a row if any condition is true.
Order By
Sorts the result.