VCF

Unit 7 · Data that lasts

SQL text values need single quotes

Without quotes, SQL reads Toronto as the name of a column and fails. Put text values in single quotes: WHERE city = 'Toronto'. Numbers need no quotes.

The mix-up

What people often think

“Text values can be typed as they are, like numbers.”

What the tutor says

Without quotes, SQL thinks Toronto is the name of a column. Put text in single quotes: 'Toronto'.

How it works

Use single quotes for text in SQL. Many databases read double quotes as names of columns or tables, not as text.

Side by side

The mix-upSQL
SELECT * FROM customers WHERE city = Toronto;
Looks for a column called Toronto.
What worksSQL
SELECT * FROM customers WHERE city = 'Toronto';
A text value.

Practise it with a tutor watching

Tables and rows

Read a database table and write SELECT, INSERT and a safe UPDATE in SQL.

20 minutes See it Build it Break it Say it
Start the lesson

Free, no account needed.