Skip to content

[Bug]: SQL Parser Error with CASE Statement and Table Alias #19656

@chmanagetech

Description

@chmanagetech

Describe the bug

After upgrading to phpMyAdmin 5.2.2, the SQL parser generates an error when executing queries that contain both a CASE statement and table aliases. The issue is reproducible in both cPanel environments and local Docker installations, suggesting it's related to the SQL parser library rather than the environment.

How to Reproduce

  1. Upgrade phpMyAdmin to version 5.2.2
  2. Create or access an existing table (e.g., tblinvoices)
  3. Run the following SQL query in the SQL tab:

SELECT CASE WHEN t.status = 1 THEN t.userid WHEN t.status = 2 THEN t.id END AS teststatus FROM tblinvoices AS t ORDER BY t.id LIMIT 10;

Expected behavior

The SQL parser shows an error and fails to execute the query despite the SQL syntax being valid.

Screenshots

The query should execute successfully and return results, as the SQL syntax is correct according to MySQL/MariaDB standards.

Operating System

macOS

Web Server

No response

Database Server

MySQL

Database version

No response

PHP version

No response

phpMyAdmin version

5.2.2

browser

No response

Additional context

This appears to be related to the issue described in the GitHub repository:

phpmyadmin/sql-parser#588
The query works correctly when executed directly in MySQL/MariaDB command line or other SQL clients
The issue specifically occurs when combining CASE statements with aliases in the SELECT clause

Metadata

Metadata

Assignees

Labels

BugA problem or regression with an existing featureduplicate

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions