If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Select Sql Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-17-07, 13:58
venky5436 venky5436 is offline
Registered User
 
Join Date: Jul 2005
Posts: 47
Question Select Sql Error

Hi All,

PLease help me solve this syntax error.

select * ,'ALL' as all from TEST.SAMPLE;

Error:
3:42:37 [SELECT - 0 row(s), 0.000 secs] [Error Code: -104, SQL State: 42601] An unexpected token "*" was found following "select ". Expected tokens may include: "?".

Trying to add a column to the select results.

Thanks in Advance,
Venky
Reply With Quote
  #2 (permalink)  
Old 08-17-07, 14:33
myBoo myBoo is offline
Registered User
 
Join Date: May 2007
Posts: 27
Select * tells DB2 to Select all columns.
Your statement should look like - SELECT * FROM Test.Sample

When naming your own column in your results you would do something like:
SELECT count(*) as CNT FROM Test.Sample
or
SELECT fName as FirstName FROM Test.Sample
Reply With Quote
  #3 (permalink)  
Old 08-17-07, 14:35
nidm nidm is offline
Registered User
 
Join Date: May 2003
Posts: 113
Quote:
Originally Posted by venky5436
Hi All,

PLease help me solve this syntax error.

select * ,'ALL' as all from TEST.SAMPLE;

Error:
3:42:37 [SELECT - 0 row(s), 0.000 secs] [Error Code: -104, SQL State: 42601] An unexpected token "*" was found following "select ". Expected tokens may include: "?".

Trying to add a column to the select results.

Thanks in Advance,
Venky
try:
select T.* ,'ALL' as all from TEST.SAMPLE T;
Reply With Quote
  #4 (permalink)  
Old 08-17-07, 15:18
venky5436 venky5436 is offline
Registered User
 
Join Date: Jul 2005
Posts: 47
Quote:
Originally Posted by nidm
try:
select T.* ,'ALL' as all from TEST.SAMPLE T;

Thanks this works,
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On