November 5, 2009 at 2:46 am
Dear All,
I need to add a row to the result of SQL statement.
The Sql Statement is:
select ID, name from myTable;
the result:
ID name
1 name1
2 name2
3 name3
the previous result comes from the table, but I need to add a row in the result which is not in the table.
Is it possible to display a row in the result which does not exist in the table?
Regards
November 5, 2009 at 2:54 am
obarahmeh (11/5/2009)
Dear All,I need to add a row to the result of SQL statement.
The Sql Statement is:
select ID, name from myTable;
the result:
ID name
1 name1
2 name2
3 name3
the previous result comes from the table, but I need to add a row in the result which is not in the table.
Is it possible to display a row in the result which does not exist in the table?
Regards
take the result in temporary table and add a new row and list it
kshitij kumar
kshitij@krayknot.com
www.krayknot.com
November 5, 2009 at 3:09 am
you have an advantae with this that, if any duplicates are there, its removed.
Create table #t(ID int, Name varchar(10))
INSERT INTO #t VALUES (1, 'abc')
INSERT INTO #t VALUES (2, 'def')
INSERT INTO #t VALUES (3, 'ghi')
SELECT * from #t
UNION
SELECT 4, 'jkl'
---------------------------------------------------------------------------------
November 5, 2009 at 6:37 am
Also union can be used
Select UserName from table B
Union
Select somecolumn as UserName from table B
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply