Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Problem

Status
Not open for further replies.

Sisto

Programmer
May 29, 2001
25
US
**ANSI SQL**
I have a field named DATE in my table.
How would I write a select statement choosing that field.

Select Date, Amount from <aTable>

The above doesn't work because Date is a key word.

My Table needs to look like:

Date Amount
---------- ------
06/03/2001 10.00
07/05/2001 5.35
.
.
.
03/18/1999 25.00
 
Use quotes &quot; and avoid using keywords as column names in the future. Wushutwist
 
Thanks &quot;wushutwist&quot; but I tried using the dble-quotes and the result looks like this:

code: Select &quot;DATE&quot;, Amount from <aTable>

result:

DATE Amount
---------- ------
DATE 10.00
DATE 5.35
.
.
.
DATE 25.00
 
Wushutwist's double quote suggestion works in Oracle. What DBMS are you using?
 
If it is Access you may need to use [Date]. I hate Access. Wushutwist
 
Hello again &quot;wushutwist&quot;, I'm using the Borland Database Engine (BDE v.5).

Thanks for the input.
MS SQL isn't so bad.

Sisto
 
You may be out of luck, but...
In ANSI SQL, you can reference a column by name, with or without the table as a prefix. You can also reference it by number - if DATE were the fourth column in the table definition, then
Select 4, Amount
From ...
You might also just try including the table name as part of the column reference, as in
Select SomeTable.DATE, Amount,
From SomeTable Malcolm Wynden
Authorized Crystal Engineer
malcolm@wynden.net
 
Thank you MalcolmW,

I am using a strange Database-engine (BDE).

The column number method did not work for me, although I did find out what does work.

It is as follows:

SELECT aTable.&quot;Date&quot; from aTable

Thanks a million for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top