# sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) 列名 'name' 有歧义

- **ID:** `python/sqlalchemy-ambiguous-column-name`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

查询连接了多个具有相同列名的表，且列引用未指定表名。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Prefix column names with table names in the query** (98% 成功率)
   ```
   session.query(User.name, Address.city).join(Address).filter(User.name == 'Alice').all()
   ```
2. **Use column_property with explicit table qualifiers** (90% 成功率)
   ```
   from sqlalchemy import column
query = session.query(column('users.name'), column('addresses.city')).select_from(User).join(Address)
   ```

## 无效尝试

- **Adding aliases to all columns indiscriminately** — Aliases may not resolve the ambiguity if the column is used in conditions. (60% 失败率)
- **Using * in SELECT** — The wildcard still produces ambiguous column references in the result set. (75% 失败率)
