2 primary command types for data manipulation language (DML)
data retrieval (“standard” queries) and action queries
example of data retrieval query in DML
select
example of DML action queries
insert, update, delete
general format for select statement
SELECT [DISTINCT | ALL] {* | column1 [AS new_name] }
FROM table_name [alias]
[WHERE conditions]
[GROUP BY column_list] [HAVING condition]
[ORDER BY column_list]
for the select statement format, can you do both for the [DISTINCT | ALL] statement
no
which of the [] {} are required, and which are optional
{} is required, [] optional
“*” is called a
wildcard
where clause is a ______ and includes the expressions:
conditional filter,
- arithmetic operators
- logical operators
- clauses
logical operators
and, or, not
clauses
between, like, in
you select WHAT from WHAT
column names from table name
“*” can replace
list of column names (lists entire table/full details)
to use the where clause to make a comparison between a field/attribute and a value, you must
use the correct syntax to indicate the (matching) data types
- creditlimit < 25
- hiredate = “2017-01-01”
using the where clause, you combine instances of _________ into _______
arithmetic comparisons, logical statements
what where clause checks to see if something does not equal a value
…WHERE NOT (X = “Thomas”)
using BETWEEN in a where clause is used with _____ to _______
logical operator AND, specify a range of values
…WHERE X BETWEEN Y AND Z
using where clause, IN can be used to ______
(plus example)
combine logical statements separated by ORs
instead of:
…WHERE (X = ‘first’) OR (X = ‘last’)
do:
…WHERE X IN (‘first’, ‘last’)
t/f: where clause can identify NULL values
true
(where x is/is not null)
using where clause, LIKE gives the ability to
do simple pattern matching
LIKE pattern always expressed as
string
with LIKE, MS Access uses
different characters than standard SQL
using LIKE to match zero or more characters in MySQL and Access
MySQL: %
Access: *
using LIKE to match exactly one character in MySQL and Access
MySQL: __
Access: #
using % for like
…WHERE Emp_LastName LIKE “Z%”