Working with Query Expressions

The definition of an expression is simple: An expression returns a value. Expression types are very broad, covering different data types such as String, Numeric, and Boolean. In fact, pretty much anything following a clause (SELECT or FROM, for example) is an expression. In the following example, AMOUNT is an expression that returns the value contained in the AMOUNT column:

SELECT amount FROM checks;

In the following statement NAME, ADDRESS, PHONE, and ADDRESSBOOK are expressions:

SELECT NAME, ADDRESS, PHONE
FROM ADDRESSBOOK;

Now, examine the following WHERE clause:

WHERE NAME = 'BROWN'

It contains a condition, NAME = 'BROWN', which is an example of a Boolean expression. NAME = 'BROWN' will be either TRUE ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.