Solved

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

Posted on 2004-09-13
3
383 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:ushastry
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:
ushastry earned 250 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

749 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