debugsqlMajor
Get a fixed value on a select
Viewed 0 times
fixedselectgetvalue
Problem
I need to do a
How do I return a constant value in 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:
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.
SELECT 'USD' AS `MONEY`, a.*
FROM INFORMATION_SCHEMA.SCHEMATA AS aJust 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 aContext
StackExchange Database Administrators Q#22192, answer score: 32
Revisions (0)
No revisions yet.