Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

Select a dummy column with a dummy value in SQL?

I have a table with the following

Table1
col1   col2
------------
 1      A 
 2      B
 3      C
 0      D

Result

col1   col2  col3
------------------
0       D     ABC

I am not sure how to go about writing the query , col1 and col2 can be selected by this

select col1, col2 from Table1 where col1 = 0;

How should I go about adding a col3 with value ABC.

question from:https://stackoverflow.com/questions/1094996/select-a-dummy-column-with-a-dummy-value-in-sql

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try this:

select col1, col2, 'ABC' as col3 from Table1 where col1 = 0;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...