Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL select statement that shows non-existant column?

Tags:

sql

select

If I have a application that accepts a query that returns 4 columns, 1 of which is an extra info column that can be empty, and the column doesn't exist in the database I am using how could I 'create' it so that the data retrieved using the query always has 4 columns, 1 nbeing empty?

like image 277
theringostarrs Avatar asked Jul 01 '09 03:07

theringostarrs


People also ask

How can I get SQL query results without column names?

To display the results of a query without column headings, use the WITHOUT HEADINGS keywords.

How do I SELECT non duplicates in SQL?

If you want the query to return only unique rows, use the keyword DISTINCT after SELECT . DISTINCT can be used to fetch unique rows from one or more columns. You need to list the columns after the DISTINCT keyword.


2 Answers

select c1, c2, c3, null as c4 from table;
like image 74
Ble Avatar answered Nov 04 '22 16:11

Ble


This would work in Oracle, haven't tried in anything else:

select null thiscolumnisempty, id,id2,id3 from table
like image 41
jle Avatar answered Nov 04 '22 16:11

jle