473,498 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql fieldname

60 New Member
hi,

i have the following:

Expand|Select|Wrap|Line Numbers
  1. $sql="SELECT 'field name here', field2, age...
  2.  
not sure how i would include a field name that contains spaces in the SELECT statement. I have an ODBC connection to MS Access..


Thanks
Jan 20 '09 #1
8 2212
Dormilich
8,658 Recognized Expert Moderator Expert
for this reason one usually does not use field names with spaces.... maybe escaping with a backslash, but I'm not sure
Jan 20 '09 #2
Markus
6,050 Recognized Expert Expert
I think, but I'm not sure, you have to do it like this (if you have spaces in field names):

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT 
  3.     `Column 1` AS Column_1
  4. FROM
  5.     ....
  6.  
  7.  
Jan 20 '09 #3
Atli
5,058 Recognized Expert Expert
I remember the Microsoft SQL server GUI thing using brackets around field names.
Maybe that would work for Access as well?

Like:
Expand|Select|Wrap|Line Numbers
  1. SELECT [Field name] FROM [My table]
Jan 20 '09 #4
geraldjr30
60 New Member
hi,

that 'field name' as field_name did not work.

In the meantime, I am just changing the table column names so they dont include spaces. But if i could figure out how to avoid changing table column names that would be helpful for those who insist that they not change.

thanks in advance,
geebee
Jan 20 '09 #5
Atli
5,058 Recognized Expert Expert
Did you try the bracket thing I put in my last post?
According to what I've read that should work.
Jan 20 '09 #6
geraldjr30
60 New Member
thanks! the brackets worked.
Jan 20 '09 #7
Markus
6,050 Recognized Expert Expert
Stupid me.. I overlooked the part about MS Access.

-_-
Jan 20 '09 #8
Markus
6,050 Recognized Expert Expert
As a side note: in MySQL 5.0.27, you can have field names with spaces in them and select them as you would any other field.

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.     `Field Column`
  3. FROM
  4.     `table`
  5.  
Jan 20 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2878
by: Margaret MacDonald | last post by:
It appears that the 'table.field' dot notation is not preserved by php's mysql library. I can create some join 'SELECT a.id, b.id FROM table1 AS a, table2 AS b' but when I try to refer to the...
4
1953
by: MARTIN DAVIES | last post by:
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)...
6
1565
by: geradeaus | last post by:
Hello, I was wondering if I could do the following : can I change the formname and fieldname with an argument? This way I can re-use the script multiple times. My code (that doesn't work): ...
3
1567
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...
1
1855
by: ad | last post by:
Hi, What is the difference between (string)dr and dr.ToString();
1
2164
by: Abe Simpson | last post by:
Hi all, My form file has this attribute: <META http-equiv="Content-Type" content="text/html; charset=utf-8"> The form's action points to an .aspx file where I try to retrieve field values...
1
1295
by: Simon | last post by:
Dear reader, If there is now broken reference in the VBA library and I run the code Mid(;3;2) an error massage can by pop's up "Not a valid instruction". After a reconnection of the...
1
2137
by: Simon | last post by:
Dear reader, The following functions gives me some problems: Mid(,3,2) and Left() and Date(). On one pc it works perfect and on the other one an error message pop's up "Not a valid...
3
3279
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5,...
3
1466
by: wquatan | last post by:
Hi For a parsing routine with more than 100 fields, I'm looking a way to get values out of Fields by determining the Fieldname on the fly. As a simple example : Let's assume the following ...
0
7124
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
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7200
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...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.