Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a blank/hardcoded column in a sql query?

Tags:

sql

coldfusion

I want have a query with a column that is a hardcoded value not from a table, can this be done? I need it basically as a placeholder that I am going to come back to later and fill in.

example:

SELECT hat, shoe, boat, somevalue = 0 as placeholder FROM objects 

then I would loop through this query later and fill in the placeholder

in this example someValue is not a field in objects, I need to fake it. I am doing this in coldfusion and using two datasources to complete one query. I have tried the space() function but have been unable to get it to work.

Thanks.

like image 793
tylercomp Avatar asked Mar 03 '11 19:03

tylercomp


2 Answers

SELECT     hat,     shoe,     boat,     0 as placeholder FROM     objects 

And '' as placeholder for strings.

like image 65
Galz Avatar answered Sep 22 '22 13:09

Galz


This should work on most databases. You can also select a blank string as your extra column like so:

Select   Hat, Show, Boat, '' as SomeValue From   Objects 
like image 38
g.d.d.c Avatar answered Sep 21 '22 13:09

g.d.d.c