FIT2094 Lecture Notes - Lecture 7: Pattern Matching, Database

80 views2 pages
W7: SQL!
Set Membership"
– Totestwhetherthevalueofexpressionequalsoneofasetofvalues. – Operator: "
IN"
– Example:cityIN(‘Melbourne’,’Sydney’) "
Pattern Match"
– Totestwhetherastring(text)matchesaspecifiedpattern. – Operator: "
LIKE – Patterns: !
% character represents any sequence of zero or more character. !
_ character represents any single character. – Example: !
WHERE city LIKE ‘M%’ !
WHERE unitcode LIKE ‘FIT91__’ "
NULL"
– To test whether a column has a NULL (unknown) !
value."
– Example: WHERE grade IS NULL. !
Use in subquery (to be discussed in the future) – ANY, ALL !
– EXISTS !
Predicate evaluation is done using three-valued logic. TRUE, FALSE and UNKNOWN !
DBMS will evaluate the predicate against each row. !
Row that is evaluated to be TRUE will be retrieved. !
NULL is considered to be UNKNOWN. "
Logical operators – AND, OR, NOT !
Rules:"
– An expression is evaluated LEFT to RIGHT."
– Sub-expression in brackets are evaluated first. – NOTs are evaluated before AND and OR"
– ANDs are evaluated before OR. !
“ORDER BY” clause. !
Order can be ASCending or DESCending. The default is "
ASCending. !
NULL values can be placed first/last using “NULLS LAST” "
or “NULLS FIRST” command !
Sorting can be done for multiple columns. "
– order of the sorting is specified for each column. !
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents