Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RE: phantom records

1 view
Skip to first unread message

sloan

unread,
Mar 29, 2006, 3:25:07 PM3/29/06
to
select top 3 iUserID , sFirstName , sLastName from tblUser
UNION
select -9999 , 'Fake', 'User'

Hi all:

I realize that this is strictly speaking not an ASP.NET question, but
since most of you people out there SQL gurus as well, I hope you will
bear with me on this occasion:

I would like to know how to create a "phantom" record when running a
SELECT query.

For example:

Running "Select ID, Firstname, Lastname from Customers order by
Lastname" would produce a list all the records in the Customers table
such as:

1 John Brown
2 Anne Johnsen
3 Tom Smith


But I would like the first the result of such a query to contain a
"virtual record", i.e information that I have manually inserted into
the query and does not correspond to any record.

So, by way of an example how do I ensure a return like this:

0 PETER JENSEN
1 John Brown
2 Anne Johnsen
3 Tom Smith

when there is no record containing the information "0 Peter Jensen"?

Thanks.

TB


shankar

unread,
Mar 30, 2006, 11:28:03 AM3/30/06
to
Select 0 as id,'PETER' as Firstname,'JENSEN' as Lastname
UNION

Select ID, Firstname, Lastname from Customers order by
Lastname
0 new messages