dmwoodru
asked on
How to SELECT from table with ampersand ('&') in column name?!
Hi, I have unfortunately inherited a table that has data in it and that has an ampersand in one of the column names.
A 'desc table' provides the following:
mysql> desc benefits;
+------------------+------ ------+--- ---+-----+ ---------+ ---------- ------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------ ------+--- ---+-----+ ---------+ ---------- ------+
| ID | int(11) | | PRI | NULL | auto_increment |
[...]
| JITJ&T | int(11) | YES | | NULL | |
How do I select from the 'JITJ&T' column?
A 'desc table' provides the following:
mysql> desc benefits;
+------------------+------
| Field | Type | Null | Key | Default | Extra |
+------------------+------
| ID | int(11) | | PRI | NULL | auto_increment |
[...]
| JITJ&T | int(11) | YES | | NULL | |
How do I select from the 'JITJ&T' column?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ushastry's answer was perfect! Thanks very much. All points assigned to ushastry.
if you are getting problem in select query, then you can just rename the column name..
ALTER TABLE benefits CHANGE `JITJ&T` `JITJT` INT(11) DEFAULT NULL;