Docsity

Parenthesis - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

Toggle sidebar
bg1
WHERE Clause
• Can use Boolean AND, OR or NOT to join
statements together.
• Should use ( ) around clauses and around
entire thing if multiple clauses.
• Can use traditional < > =
• Also can use Math Operators: + - * /
• Also can use LIKE with wildcards (% or *)
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Parenthesis - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

WHERE Clause

  • Can use Boolean AND, OR or NOT to join

statements together.

  • Should use ( ) around clauses and around

entire thing if multiple clauses.

  • Can use traditional <
  • Also can use Math Operators: + - * /• Also can use

LIKE

with wildcards (

or

Use of Like

-^

SQL’s response to case varies by database so in lookingfor all of the people who start with ‘SM’ we could (

Access

*uses , ANSI SQL %

):

...Where ( (LastName Like ‘SM’) or (Name Like ‘sm’) or (Name

Like ‘Sm*’) )

-^

If you know your database is case insensitive, you cansimplify your queries considerably:

…Where (LastName Like 'SM%')

-^

Notice to be safe we use ( ) around clauses. Wild cards canbe in front, back or both.

-^

Like clauses where the wild card is at the end are fasterthen mixed or at the beginning of the field to be searched.

Where : IN

  • In is handy in Where clauses to identify a

subset of the records to be examined.

  • Can be a list or the results of a sub-query.^ Select Name, YearBorn From Authors Where

YearBorn In (1962, 1963, 1964)

Sub Queries - I

  • In previous example if years had been in the

HoleInOne

table and we wanted a list of all

authors born in years that had a hold in onewe could:

Select Name, YearBorn From Authors Where

YearBorn In (Select Year From HoleInOne)

-^

Notice we only return the ONE field in the subquery corresponding to the field in the Whereclause.

SQL Overview

Day 2: Joins