liveBook · Manning

String

As explained in Learn SQL in a Month of Lunches

A string is a sequence of characters treated as text data.

A string is text data: a group of characters such as a title, name, or payment method. In SQL filters, enclose string values in straight single quotes. Without them, a non-numeric filter value causes a syntax error. section 5.1.2

Find a title by name

SELECT Advance FROM title WHERE TitleName = 'Anne of Fact Tables'; The quoted value must exactly match the stored value. A missing character, extra space, tab, or carriage return can change the result to no rows. Use ordinary keyboard single quotes, not typographic quotes copied from a document. section 5.1.2

SELECT Advance
FROM title
WHERE TitleName = 'Anne of Fact Tables';

Use the complete query to see how a string value appears in a practical WHERE condition. section 5.1.2

String searches can use ranges, but wildcard patterns are clearer when the goal is to match a pattern such as surnames beginning with S. Range results can vary with collation, letter case, and accented characters. section 7.1

Strings also appear in other SQL tasks:

  • Combine two or more strings by concatenating them with the CONCAT function; do not assume that the plus sign performs this job across database systems. section 15.1
  • Assign a string to a MySQL user-defined variable with SET, then inspect it with SELECT. section 13.1.1
  • Keep numeric values unquoted when filtering numeric columns, because implicit conversion can reduce query performance on larger data sets. section 5.4

How Learn SQL in a Month of Lunches covers it

How deep it goes
Explains quoting, exact matching, hidden characters, ranges, wildcards, variables, concatenation, and database-specific behavior.
Examples
Uses title-name and author-name filters, payment-method conditions, a MySQL title variable, and attempted arithmetic-style concatenation.
What it assumes
Assumes basic SQL filtering and SELECT statements while teaching string syntax, exact matching, and text-specific operations from practical examples.
What you can do after
Apply strings in SQL filters, pattern searches, variables, and concatenation while avoiding quoting, whitespace, and portability errors.
How it connects
Connects strings with WHERE clauses, wildcards, collation, user-defined variables, CONCAT, implicit conversion, and query performance.

Also explained in

Compare how 24 books explain string →

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.