#1356·alasql

Execution gives wrong result when field name starts from number

Author: Soni-GoyalCreated Jul 5, 2021Updated Sep 10, 2026
LabelsHelp wantedRelated to: Code qualityRelated to: SQL complianceBug: Code provided to reproducedGood first issue

Hi,

  1. I have executed a query
SELECT 5g_enabled FROM subscription WHERE [5g_enabled] = 'YES'"

and my table contains 3 results for YES value but when parser runs its giving me g_enabled as field name and value as 5. If I run

SELECT 5g_enabled FROM subscription WHERE 5g_enabled = 'YES'"

, this results into parser error Parse error on line 1: ...iption_event WHERE 5g_enabled = "YES" -----------------------^ Expecting 'EOF', 'WITH', 'RPAR', 'IN', 'LIKE', 'ARROW', 'DOT', 'ORDER', 'CARET', 'EQ', 'SLASH', 'EXCLAMATION', 'MODULO', 'GT', 'LT', 'GTGT', 'LTLT', 'NOT', 'UNION', 'INTERSECT', 'EXCEPT', 'AND', 'OR', 'PLUS', 'STAR', 'GROUP', 'LIMIT', 'OFFSET', 'END', 'ELSE', 'REGEXP', 'TILDA', 'GLOB', 'NOT_LIKE', 'BARBAR', 'MINUS', 'AMPERSAND', 'BAR', 'GE', 'LE', 'EQEQ', 'EQEQEQ', 'NE', 'NEEQEQ', 'NEEQEQEQ', 'BETWEEN', 'NOT_BETWEEN', 'IS', 'DOUBLECOLON', 'GO', 'SEMICOLON', got 'LITERAL' Can you please help me to check why this is giving wrong results ?

  1. In another example , I had to execute a query where I was naming tables due to nested query but on parsing , table name is removed from fieldname
SELECT Count(so.[5g_enabled])  FROM subscription_event as so WHERE [5g_enabled] = "TRUE"

After parsing I am not getting columnId as so.5g_enabled rather it gives only 5g_enabled

{"statements":[{"columns":[{"aggregatorid":"COUNT","expression":{"columnid":"5g_enabled","tableid":"so"}}],"from":[{"tableid":"subscription_event","as":"so"}],"where":{"expression":{"left":{"columnid":"5g_enabled"},"op":"=","right":{"value":"TRUE"}}}}]}