# sql: no rows in result set

- **ID:** `go/sql-no-rows-in-result-set`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

QueryRow.Scan found no matching row. Code treats sql.ErrNoRows as a fatal error instead of a normal not-found case.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   err := db.QueryRowContext(ctx, q, id).Scan(&u.Name)
if errors.Is(err, sql.ErrNoRows) {
  return nil, ErrNotFound
}
return &u, err
   ```
2. **** (82% success)
   ```
   Use SELECT COUNT(*) first when existence matters, or return a typed ErrNotFound.
   ```

## Dead Ends

- **** — Still returns zero rows; the error handling issue remains. (70% fail)
- **** — Does not change the no-rows case. (85% fail)
