Reputation: 920
I can't seem to figure out how to do the following in an IBM DB2 select statement:
SELECT column1, *
FROM [some table]
I get the following error:
SELECT ACCT_NUM, * FROM GEG1.RENL_RATING_STRUC
SQL0104N An unexpected token "*" was found following "". Expected tokens may include: "+ - ROW NEXTVAL PREVVAL NEXT PREVIOUS ( <INTEGER> <DECIMAL>". SQLSTATE=42601
I searched for a syntax document, but I couldn't find one. Can anyone help with this?
Upvotes: 0
Views: 3203
Reputation: 15450
If you give the table an alias, you can prefix the asterisk with the alias to do what you want:
SELECT A.id, A.*
FROM your_table A
You have to interpret the select-clause
definition from this page:
.-ALL------.
>>-SELECT--+----------+----------------------------------------->
'-DISTINCT-'
>--+-*-----------------------------------------------+---------><
| .-,-------------------------------------------. |
| V | |
'---+-expression--+-------------------------+-+-+-'
| | .-AS-. | |
| '-+----+--new-column-name-' |
'-exposed-name.*--------------------------'
So, this basically reads "you can SELECT *
OR you can select multiple expressions (a column) or exposed-name.*
, separated by a comma".
Upvotes: 2