liveBook · Manning

Single quotation mark

As explained in Learn SQL in a Month of Lunches

A single quote is the quotation delimiter used in SQL to enclose literal character and date values.

In SQL, single quotation marks enclose literal character values, such as a title name, when they appear in a filter. Without them, a string value causes a syntax error. section 5.1.2

Filtering for a title

SELECT Advance FROM title WHERE TitleName = 'Anne of Fact Tables'; The value inside the quotes must match the stored text exactly. An omitted letter, extra space, tab, or carriage return can produce no results. section 5.1.2

Use single quotation marks carefully:

  • Use the straight single quote on the same keyboard key as the double quote; typographic quotes copied from documents can cause syntax errors. section 5.1.2
  • Enclose date and time values in single quotes, commonly using the year-month-day format followed by hours, minutes, and seconds. section 5.1.3
  • Do not quote numeric values unnecessarily; implicit conversion may reduce query efficiency on larger data sets. section 5.4

A date value

SELECT TitleName, PublicationDate FROM title WHERE PublicationDate = '2020-03-14'; A date without a time is treated as midnight, or 00:00:00. Include time precision when the stored value contains meaningful hours, minutes, or seconds. section 5.1.3

How Learn SQL in a Month of Lunches covers it

How deep it goes
Explains syntax, exact matching, malformed quote characters, date precision, and conversion costs, but does not cover broader quoting rules.
Examples
Demonstrates title-name filters, publication-date filters, an extra-space failure, copied typographic quotes, and a payment-method condition.
What it assumes
Assumes basic SQL filtering and distinguishes numeric values from strings and dates through worked examples.
What you can do after
Apply single quotation marks in SQL filters while avoiding character mismatches, inappropriate numeric quoting, and lost time precision.
How it connects
Connects single quotation marks with SQL string values, date and time values, WHERE clauses, AND, OR, and implicit type conversion.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn SQL in a Month of Lunches. The section links point to the parts of the book it draws on.