Solved

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

Posted on 2004-09-13
3
378 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

860 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