tags:

views:

569

answers:

4

Hi,

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?

+1  A: 

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

select null thiscolumnisempty, id,id2,id3 from table
jle
That will work in Sybase, and probably MySQL as well, it's fairly standard.
glasnt
+5  A: 
select c1, c2, c3, null as c4 from table;
Ble
A: 

You can have 3 fields in database table, but return 4 columns in your sql SELECT script:

SELECT id, column2, column3, id FROM YourTable;

So you'll get 4 columns return but 3 real columns in db table.

zdmytriv
A: 

select c1, c2, c3, '' as c4 from table; select c1, c2, c3, 0 as c4 from table; if you want int then take 0 or if you want varchar then take ''.

KuldipMCA