Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    47

    Question Unanswered: 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

  2. #2
    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

  3. #3
    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;

  4. #4
    Join Date
    Jul 2005
    Posts
    47
    Quote Originally Posted by nidm
    try:
    select T.* ,'ALL' as all from TEST.SAMPLE T;

    Thanks this works,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •