开发者

How Show tablename with resultset in query?

I have a used query as follows:

SELECT LTRIM(RTRIM(ClaimsAdminName)) + ' | ' + LTRIM(RTRIM(ClaimsAdminID)) AS Clientname
FROM tblClaimsAdmin
WHERE (ClaimsAdminName LIKE @Prefix)
UNION
SELECT LTRIM(RTRIM(EmployerFName + ' ' 开发者_如何转开发+ EmployerLName)) + ' | ' + LTRIM(RTRIM(EmployerID)) AS Clientname
FROM tblEmployer
WHERE (EmployerFName LIKE @Prefix)

The result returned if I enter 's%' is :

s | 8 Sumit Singh | 16

Now is there any way so that i can return the tablename with the result set.Like from which table the value is coming.

I hope I am clear with my query.

Please help!

Thanks

Swaroop Kumar.P


select 'table1' as tablename, otherfields
from table1
union all
select 'table2', otherfields
from table2
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜