# error: sql: Scan error on column index 0: converting driver.Value type []uint8 ("123") to a int: invalid syntax

- **ID:** `go/database-sql-scan-type-mismatch`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

数据库返回的数据类型与Scan目标类型不兼容，例如将字符串转换为整数时发生解析错误。

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   var id int
if err := rows.Scan(&id); err != nil {
    // 使用strconv.Atoi转换字符串
}
   ```
2. **** (90% success)
   ```
   确保数据库列类型与Scan目标类型一致，例如使用CAST或明确指定目标类型。
   ```

## Dead Ends

- **** — 类型断言不会解决转换问题，数据可能丢失或错误。 (90% fail)
- **** — 如果数据库实际是整数，改为string会丢失类型信息，后续处理麻烦。 (60% fail)
