GITTA-Logo
PDF Version of this document Search Help

Lesson Navigation IconStructured Query Language SQL

Unit Navigation IconSQL overview

Unit Navigation IconCreation and modification of tables

Unit Navigation IconBasic database queries

LO Navigation IconSelect-From-Where

LO Navigation IconMultiple conditions

LO Navigation IconComparison operators

LO Navigation IconArithmetical operators

LO Navigation IconNested queries

LO Navigation IconJoin

LO Navigation IconNon-relational constructs

LO Navigation IconSet operators

LO Navigation IconSummary

LO Navigation IconDatabase queries

Unit Navigation IconSQL Insert, Delete and Update

Unit Navigation IconUsage of SQL

Unit Navigation IconSummary

Unit Navigation IconRecommended Reading

Unit Navigation IconBibliography

Unit Navigation IconMetadata


GITTA/CartouCHe news:


Go to previous page Go to next page

Pattern matching and arithmetical operators

Pattern matching using LIKE

The LIKE condition allows you to use wildcards in the WHERE clause of an SQL statement. This allows pattern matching.
The patterns that you can choose from are:

  • "%" allows you to match any string of any length (including zero length)
  • "_" allows you to match on a single character
Pattern matching using LIKE
remark

NOT LIKE examines whether the given section is not present in the string.

Arithmetical operators

The arithmetical standard operators for addition (+), subtraction (-), multiplication (*) and division (/) can all be used for numerical constant or for attributes with a numerical domain. This allows attributes in a request to be calculated together.

Arithmetical operations query

In the above example the result is a relation with three attributes. The third attribute is named "Usury" since "Price/Size" is not a good name and stands for the price per unit. We define that if it lies over 15, it is overpriced ("Usury").

Arithmetical operators can be used in the SELECT part of a request or in the conditions.

remark In the SELECT or FROM part of a request, attributes and relations can be given a different name by the command AS: <Attribute/Relation> AS <new name> (The key word AS can be omitted). This can be used to give a calculated value a meaningful name (see example), or to make SQL requests easier to read.
Top Go to previous page Go to next page