pingcap / pingcap/tidb

TiDB does not support explicit column names in subqueries

Open
#65,151 4 comments 1 reaction 0 assignees View on GitHub
compatibility-mysql8 compatibility-mysql80 compatibility-mysql84 severity/moderate sig/sql-infra type/bug type/compatibility
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

```
SELECT * FROM (SELECT 1 x) a(x);
SELECT * FROM (SELECT 1 a, 2 b, 3 c) abc(x,y,z);
```

### 2. What did you expect to see? (Required)

MySQL 8.4.7
```
mysql-8.4.7 [(none)]> SELECT * FROM (SELECT 1 x) a(x);
+---+
| x |
+---+
| 1 |
+---+
1 row in set (0.001 sec)

mysql-8.4.7 [(none)]> SELECT * FROM (SELECT 1 a, 2 b, 3 c) abc(x,y,z);
+---+---+---+
| x | y | z |
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
1 row in set (0.001 sec)
```

### 3. What did you see instead (Required)

```
mysql-8.0.11-TiDB-v9.0.0-beta.2.pre-935-g969d090c0b [(none)]> SELECT * FROM (SELECT 1 x) a(x);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 29 near "(x)"
mysql-8.0.11-TiDB-v9.0.0-beta.2.pre-935-g969d090c0b [(none)]> SELECT * FROM (SELECT 1 a, 2 b, 3 c) abc(x,y,z);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 41 near "(x,y,z)"
mysql-8.0.11-TiDB-v9.0.0-beta.2.pre-935-g969d090c0b [(none)]>
```

### 4. What is your TiDB version? (Required)

```
Release Version: v9.0.0-beta.2.pre-935-g969d090c0b
Edition: Community
Git Commit Hash: 969d090c0bb765d041eec97c63ec37179e78ea54
Git Branch: master
UTC Build Time: 2025-12-21 08:56:16
GoVersion: go1.25.5 X:nodwarf5
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Kernel Type: Classic
```

### Related docs

- https://dev.mysql.com/doc/refman/8.4/en/derived-tables.html
- https://modern-sql.com/feature/table-column-aliases

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.