sql: no rows in result set Go Origin: Application & API Last updated 4 Nov 2026

Go: sql: no rows in result set

QueryRow(...).Scan(...) found no row for the query.

Exact message you may see sql: no rows in result setno rows in result set Scanpgx: no rows in result set
Seen on: Go

Meaning

This is a normal "not found" signal, not a database failure. Compare with errors.Is(err, sql.ErrNoRows) and return a 404 or default. If rows were expected, check the WHERE clause, parameters and that you query the correct database/schema.

Common causes

  • No matching row for the ID or filter
  • Wrong parameter value or type
  • Querying the wrong database/schema
  • Row not yet committed (another transaction)
  • Soft-deleted row filtered out

⚡ Quick fix

  1. Handle sql.ErrNoRows explicitly
  2. Log the SQL parameters
  3. Verify the data exists with a direct query

Detailed fix by platform

Go

  1. if errors.Is(err, sql.ErrNoRows) { return nil, ErrNotFound }

How to diagnose

  1. Query — Parameters correct?
  2. DB — Right database?
  3. Data — Row exists?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

assignment mismatch: 1 variable but f returns 2 values — Go: assignment mismatch: 1 variable but os.Open returns 2 values (Go)assignment mismatch: …cannot assign to struct field m[k].f in map — Go: cannot assign to struct field users["bob"].Age in map (Go)cannot assign to stru…cannot find package in any of GOROOT / GOPATH — Go: cannot find package "github.com/pkg/errors" in any of: /usr/local/go/src/github.com/pkg/errors (from $GOROOT) /go/src/github.com/pkg/errors (from $GOPATH) (Go)cannot find package i…cannot use x as type in assignment/argument — Go: cannot use "5" (untyped string constant) as int value in argument to f (Go)cannot use x as type …listen tcp :8080: bind: address already in use — Go: listen tcp :8080: bind: address already in use (Go)listen tcp :8080: bin…MySQL: SSL connection error: SSL is required but the server doesn't support it — MySQL: ERROR 2026 (HY000): SSL connection error: SSL is required but the server doesn't support it (SSL / TLS)MySQL: SSL connection…panic: assignment to entry in nil map — Go: panic: assignment to entry in nil map (Go)panic: assignment to …root certificate file "root.crt" does not exist — PostgreSQL: root certificate file "/home/user/.postgresql/root.crt" does not exist. Either provide the file or change sslmode (SSL / TLS)root certificate file…sql: no r…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.