Solved

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

Posted on 2004-09-13
3
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

729 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