select columname,* from tablename
error
-----
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 10 Column: 17
CodePudding user response:
That error is caused by the use of the asterisk without a table prefix.
While it IS valid to use select * from tablename
, in Oracle, if you add a column into that query you MUST specify what table the asterisk refers to like this select columname1, tablename.* from tablename
. This is demonstrated below:
CREATE table tablename ( columnname1 INT, columnname2 DATE, columnname3 FLOAT );
select columnname1,* from tablename
ORA-00936: missing expression
select columnname1, tablename.* from tablename
COLUMNNAME1 | COLUMNNAME1 | COLUMNNAME2 | COLUMNNAME3 ----------: | ----------: | :---------- | ----------:
db<>fiddle here
This also applies to table aliases, this will still fail
select columnname1,* from tablename t1
but this is valid
select columnname1,t1.* from tablename t1
CodePudding user response:
use an alias
select columname,t1.* from tablename t1