Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to SELECT from table with ampersand ('&') in column name?!

Posted on 2004-09-13
3
Medium Priority
?
440 Views
Last Modified: 2013-11-19
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?
0
Comment
Question by:dmwoodru
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Umesh
ID: 12042308
Hi,

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;
0
 
LVL 26

Accepted Solution

by:
Umesh earned 1000 total points
ID: 12042396
try this..

make sure JITJ&T is in between ` & not in '

SELECT `JITJ&T`  FROM benefits
0
 

Author Comment

by:dmwoodru
ID: 12049644
ushastry's answer was perfect! Thanks very much. All points assigned to ushastry.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question