Learning Basic Query Syntax

As you will find, syntax in SQL is quite flexible, although there are rules to follow as in any programming language. A simple query illustrates the basic syntax of a SQL SELECT statement. Pay close attention to the case, spacing, and logical separation of the components of each query by SQL keywords.

SELECT NAME, STARTTERM, ENDTERM
FROM PRESIDENTS
WHERE NAME = 'LINCOLN';

In this example, everything is capitalized, but it doesn't have to be. The preceding query would work just as well if it were written like this:

select name, startterm, endterm
from presidents
where name = 'LINCOLN';

Notice that LINCOLN appears in capital letters in both examples. Although actual SQL statements are not case sensitive, references ...

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.