开发者

How do I create an SQL query that returns constant data?

开发者 https://www.devze.com 2023-02-15 01:42 出处:网络
How do I create an SQL query that returns constant data? Som开发者_StackOverflow社区ething like select ((\"col1val1\", \"col2val1\"), (\"col1val2\", \"col2val2\"))SELECT \'col1val1\',\'col2val1\'

How do I create an SQL query that returns constant data?

Som开发者_StackOverflow社区ething like

select (("col1val1", "col2val1"), ("col1val2", "col2val2"))


SELECT 'col1val1','col2val1'
UNION
SELECT 'col1val2','col2val2'
UNION
SELECT ...etc...

Write a macro to do this for you, do it in Excel (my favorite), or adjust your constraints.


select 'col1val1', 'col2val1'
union
select 'col1val2', 'col2val2'


I don't know why do you want to do that but you could use something like:

Select 'col1val1', 'col2val1', 'col1val2', 'col2val2' from ...


  1. Create a simple, regular table.
  2. Insert all data that you want there.
  3. REMOVE insert, delete and update rights from all relevant loggable accounts (only for that table, of course).

Voilà! Now you have a constant, read-only table!! You can use regular SELECTs over it, and you'll never be worried by any kind of data change.

Other than that, sorry, your only option will be using SELECT 'BlahBlahBlah' UNION......

0

精彩评论

暂无评论...
验证码 换一张
取 消