# syntax error at or near "FROM" / near "FROM": syntax error

Source: https://sqlstreak.com/sql/errors/syntax-error-at-or-near · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** The parser hit something it didn't expect just before the word in the message. Look at what comes right before it: most often a trailing comma, a missing comma, an unclosed quote or a reserved word used as a name.

## The exact messages

- PostgreSQL: `ERROR: syntax error at or near "FROM"`
- SQLite: `near "FROM": syntax error`

## How PostgreSQL prints it

```
ERROR:  syntax error at or near "FROM"
LINE 2: FROM pets;
        ^
```

## Why it happens

### A trailing comma before FROM

`SELECT name, age, FROM pets` — the comma promises another column that never comes.

### A reserved word as a column name

Columns called `order`, `user` or `group` must be quoted: `"order"`. Better: rename them.

### A missing comma

`SELECT name age FROM pets` reads as “name, renamed to age”, and the next error can appear far away.

### An unclosed quote or parenthesis

Everything after it becomes part of the string, so the error points somewhere unexpected.

## The broken query

```sql
SELECT name, age,
FROM pets;
```

## The fix

```sql
SELECT name, age
FROM pets;
```

Remove the comma after the last column. Many people put commas at the start of lines (`, age`) to make this mistake impossible.

| name | age |
| --- | --- |
| Biscuit | 3 |
| Mochi | 2 |
| Pickles | 7 |
| Luna | 5 |
| Waffles | 1 |
| Bruno | 9 |

(6 of 20 rows)
