HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMajor

Get a fixed value on a select

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
fixedselectgetvalue

Problem

I need to do a SELECT query where I get the value of the field "money". The field doesn't actually exist in the database. I just need the query to return this field with a fixed value; in this case a value in USD.

How do I return a constant value in a SELECT statement?

Solution

If the value is always going to be the same you can do something like this:

SELECT 'USD' AS `MONEY`, a.*
  FROM INFORMATION_SCHEMA.SCHEMATA AS a


Just replace a.* with the columns you want to return and INFORMATION_SCHEMA.SCHEMATA with the schema and table(s) you want to query.

I hope this is helpful to you.

Code Snippets

SELECT 'USD' AS `MONEY`, a.*
  FROM INFORMATION_SCHEMA.SCHEMATA AS a

Context

StackExchange Database Administrators Q#22192, answer score: 32

Revisions (0)

No revisions yet.