473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A hash at the end of a fieldname does not work

I hope you can help.

My Linux MYSQL 3.23.52 database server is working OK generally.

However, in a database I have a field name that ends with a # (hash UK as
opposed to £ which is a pound UK) i.e. [empnumber#]

If I "select * from emptable" it works fine and the empnumber# field is
listed correctly with all the other fields.

If I "select empnumber# from emptable" I get returned "unknown column
'empnumber' in 'field list'" (#1054) from Access 2000.

If I use Mysql on the server I get similar results.

I cannot change the field names as these are constrained by the fact that
this is not a new design of database.

Any Ideas?

Martin.
Jul 20 '05 #1
4 1943
MARTIN DAVIES wrote:
I hope you can help.

My Linux MYSQL 3.23.52 database server is working OK generally.

However, in a database I have a field name that ends with a # (hash UK as
opposed to £ which is a pound UK) i.e. [empnumber#]

If I "select * from emptable" it works fine and the empnumber# field is
listed correctly with all the other fields.

If I "select empnumber# from emptable" I get returned "unknown column
'empnumber' in 'field list'" (#1054) from Access 2000.

If I use Mysql on the server I get similar results.

I cannot change the field names as these are constrained by the fact that
this is not a new design of database.

Any Ideas?


Use backticks ` around the fieldnames eg
SELECT `empnumber#` FROM emptable

I just tested it and it works with backticks if the fieldname ends in a
hash. Using square brackets around the fieldnames is what you do with MSSQL
Server and it doesn't work with MySQL (at least it didn't when I just tried
now).

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Jul 20 '05 #2
Chris,

Thanks for the suggestion.
I have tried it and the error message goes away, but for each record
returned, the field seems to be the string : "employee#" rather than the
actual data from the table column headed employee#.

What did you get?

If you have any further suggestions I will be grateful.

Thanks,

Martin.

cc rest of group : Any (polite) suggsestions welcome


Chris Hope <ch***@electrictoolbox.com> wrote in message
news:10*************@news.athenanews.com...
MARTIN DAVIES wrote:
I hope you can help.

My Linux MYSQL 3.23.52 database server is working OK generally.

However, in a database I have a field name that ends with a # (hash UK as opposed to £ which is a pound UK) i.e. [empnumber#]

If I "select * from emptable" it works fine and the empnumber# field is
listed correctly with all the other fields.

If I "select empnumber# from emptable" I get returned "unknown column
'empnumber' in 'field list'" (#1054) from Access 2000.

If I use Mysql on the server I get similar results.

I cannot change the field names as these are constrained by the fact that this is not a new design of database.

Any Ideas?
Use backticks ` around the fieldnames eg
SELECT `empnumber#` FROM emptable

I just tested it and it works with backticks if the fieldname ends in a
hash. Using square brackets around the fieldnames is what you do with

MSSQL Server and it doesn't work with MySQL (at least it didn't when I just tried now).

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/

Jul 20 '05 #3
Oops, a slight mistake in the last request for help.
I used ' (single quote) and not ` (backticks) as advised.

It did not fix the problem anyhow, but the symptom I described is not
aligned with back ticks.

With back ticks I still get "unknown column 'employee"

I still need help though!

Regards,

Martin.
MARTIN DAVIES <ma***********@tesco.net> wrote in message
news:X4**************@newsfe3-win.server.ntli.net...
Chris,

Thanks for the suggestion.
I have tried it and the error message goes away, but for each record
returned, the field seems to be the string : "employee#" rather than the
actual data from the table column headed employee#.

What did you get?

If you have any further suggestions I will be grateful.

Thanks,

Martin.

cc rest of group : Any (polite) suggsestions welcome


Chris Hope <ch***@electrictoolbox.com> wrote in message
news:10*************@news.athenanews.com...
MARTIN DAVIES wrote:
I hope you can help.

My Linux MYSQL 3.23.52 database server is working OK generally.

However, in a database I have a field name that ends with a # (hash UK as opposed to £ which is a pound UK) i.e. [empnumber#]

If I "select * from emptable" it works fine and the empnumber# field is listed correctly with all the other fields.

If I "select empnumber# from emptable" I get returned "unknown column
'empnumber' in 'field list'" (#1054) from Access 2000.

If I use Mysql on the server I get similar results.

I cannot change the field names as these are constrained by the fact that this is not a new design of database.

Any Ideas?


Use backticks ` around the fieldnames eg
SELECT `empnumber#` FROM emptable

I just tested it and it works with backticks if the fieldname ends in a
hash. Using square brackets around the fieldnames is what you do with

MSSQL
Server and it doesn't work with MySQL (at least it didn't when I just

tried
now).

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/


Jul 20 '05 #4
MARTIN DAVIES wrote:
Oops, a slight mistake in the last request for help.
I used ' (single quote) and not ` (backticks) as advised.

It did not fix the problem anyhow, but the symptom I described is not
aligned with back ticks.

With back ticks I still get "unknown column 'employee"

I still need help though!


Re-reading your original post, I saw you'd also been using Access. Remember
that the query in Access will need [square brackets] and the query in MySQL
will need `backticks`. You won't be able to use the same query for both.

And from the example you have supplied in this post you say the error
message is "unknown column 'employee" - did you copy and paste that error
or type it in? If copy and paste, then you don't have the # at the end of
the fieldname (if you typed it in then I'd assume you just forgot to type
it in).

Assuming the query is successful, and the data is loaded into an array using
mysql_fetch_assoc() or mysql_fetch_array() you need to make sure you use
quotes to reference the value eg $foo['employee#'] or $foo["employee#"]
where $foo is the array returned by the aforementioned functions (it's good
practice to always use quotes for associative array indexes anyway).

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yimin Rong | last post by:
Does anyone know if there are any browsers where you must specify "#" as a prefix when setting the hash for the location? For example, the following would move to the intro section of the...
3
by: Murali | last post by:
I have a requirement where I have to use two unsigned ints as a key in a STL hash map. A couple of ways to do this is 1. create a struct with two unsigned ints and use that as key (write my own...
3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
31
by: Alexis Nikichine | last post by:
Hello, It is common knowledge that arrays can be used as hashtables: var color = ; color = 0xFF0000; color = 0x0000FF;
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
3
by: Sagaert Johan | last post by:
The update seems to fail becorse of the fieldname in my DB One of the fields is called "Zone" in my MDB If i change the fieldname in both the database and in my test application, the error is...
44
by: gokkog | last post by:
Hi there, There's a classic hash function to hash strings, where MULT is defined as "31": //from programming pearls unsigned int hash(char *ptr) { unsigned int h = 0; unsigned char *p =...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
8
by: Jim Cobban | last post by:
I am writing a program in which I need a hash table implementation of a Map. The version of g++ available for Windo$e does not yet include the TR1 support for this. It just has the original SGI...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.