Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to add an additional column after SELECT *?

Tags:

sql

select

oracle

I would like to SELECT all the columns from my employees table + a an additional calculated column from the same table without manually typing all the columns.

I have thought about this:

SELECT *, salary *2 FROM employees;

However attempting to do so I get the error:

  1. 00000 - "FROM keyword not found where expected"
like image 803
Adrian Danlos Avatar asked Jan 01 '23 07:01

Adrian Danlos


2 Answers

You would need to alias the table :

SELECT e.*, e.salary *2 FROM employees e; 
like image 77
GMB Avatar answered Jan 05 '23 03:01

GMB


You can try this

SELECT employees.*, employees.salary *2 FROM employees;
like image 36
Zahid Hassan Shaikot Avatar answered Jan 05 '23 03:01

Zahid Hassan Shaikot