# unterminated quoted string at or near … / unrecognized token

Source: https://sqlstreak.com/sql/errors/unterminated-quoted-string · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** A text value opens with `'` and never closes, so the rest of the query is read as text. Add the closing quote. To put an apostrophe inside text, write it twice: `'Rocket''s best'`.

## The exact messages

- PostgreSQL: `ERROR: unterminated quoted string at or near "'Austin;"`
- SQLite: `unrecognized token: "'Austin;"`

## How PostgreSQL prints it

```
ERROR:  unterminated quoted string at or near "'Austin;"
LINE 2: WHERE city = 'Austin;
                     ^
```

## Why it happens

### A missing closing quote

`WHERE city = 'Austin;` – the semicolon became part of the text. The message quotes where the text started.

### An apostrophe inside the text

`'O'Brien'` ends the text after O. Double the apostrophe, `'O''Brien'`; that's the SQL way to write a quote inside quotes in both databases.

### Curly quotes from a document

Copying SQL from a word processor turns `'` into ‘ ’, which SQL doesn't treat as quotes. Retype them in the editor.

## The broken query

```sql
SELECT name FROM customers
WHERE city = 'Austin;
```

## The fix

```sql
SELECT name FROM customers
WHERE city = 'Austin';
```

The closing quote ends the text, so the semicolon ends the query again.

| name |
| --- |
| Maya Ortiz |
| Priya Nair |
| Lena Fischer |
