|
-
Sep 12th, 2001, 03:21 PM
#1
Thread Starter
Frenzied Member
SQL Statement: "top" field
I'm using SQL Server, and I get a syntax error on a syntax error on a statement that uses "top" as a field name. But the table has a field named top, so how I do SELECT it?
VB Code:
'This gives me an error
SQL = "SELECT myField, top, myOtherField FROM myTable"
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Sep 12th, 2001, 03:59 PM
#2
Hyperactive Member
What about (not certain - but worth a try)
SQL = "SELECT myField, [top], myOtherField FROM myTable"
or
SQL = "SELECT myField, top.myTable, myOtherField FROM myTable"
-
Sep 12th, 2001, 04:10 PM
#3
Thread Starter
Frenzied Member
No luck. I also tryed...
VB Code:
SQL = "SELECT myField, myTable.top, myOtherField FROM myTable"
SQL = "SELECT myField, myTable.[top], myOtherField FROM myTable"
SQL = "SELECT (myField, myTable.top, myOtherField) FROM myTable"
SQL = "SELECT (myField, myTable.[top], myOtherField) FROM myTable"
SQL = "SELECT (myField, top, myOtherField) FROM myTable"
SQL = "SELECT (myField, [top], myOtherField) FROM myTable"
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Sep 12th, 2001, 04:25 PM
#4
Hyperactive Member
Sorry then! It's bugging me now - so if I find something when I get to work tomorrow, I'll post the answer.
-
Sep 13th, 2001, 09:37 AM
#5
Thread Starter
Frenzied Member
I got it to work.
Code:
SQL = "SELECT myTable.myField, myTable.[top], myTable.myOtherField FROM myTable"
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Sep 13th, 2001, 09:42 AM
#6
Fanatic Member
Top is a reserved word in SQL 'SELECT TOP 5...'
It is always best to try and add a prefix if you need to use a word that is also a reserved word. Same as naming a field 'Date' SQL can get confused
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Sep 13th, 2001, 12:51 PM
#7
Hyperactive Member
CiberTHuG, it looks like you just about had every permutation, and I'm glad you finally cracked it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|