sql server和wcf服务中select语句中的树节点 [英] Tree node in select statement in sql server and wcf service

查看:68
本文介绍了sql server和wcf服务中select语句中的树节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我需要在UI页面中显示一个树节点..因为需要编写一个查询来检索SQL服务器中的数据..我试过很多方面但是没有解决。



我们正在传递用户ID并选择数据。我们需要传递选定的用户ID,我们需要在单个sp中获取数据...它的链过程



 选择 SharedUserId,isnull(U.FirstName,' ')+ ' ' + ISNULL(U.LastName,' ' as 名称
来自 UserPointDetails UD,用户U 其中 pointid = ' E9C6E263-632E-469F-99EC-0115E827310A'
UD.UserId = ' ED302157-2CAD-43BE-ABDF-6C279F4C0B5F' UD.SharedUserId = U.UserId
sharedStatus = ' 可见' UD.SharedUserId!= UD.UserId



结果



SharedUserId名称

4A0DDF0B-2F7A-480F-B3EA-ED3D052D2B97 Ramesh

847F6D81-4985-4A10-995E-B7700E776C83 Rajesh



 选择 SharedUserId,isnull(U.FirstName,' ')+ ' ' + ISNULL(U.LastName,' ' as 名称
来自 UserPointDetails UD,用户U 其中​​ pointid = ' E9C6E263-632E-469F-99EC-0115E827310A'
UD.UserId = ' 4A0DDF0B-2F7A-480F-B3EA-ED3D052D2B97' UD.SharedUserId = U.UserId
sharedStatus = ' 可见' UD.SharedUserId!= UD.UserId



结果

SharedUserId名称

ED302157-2CAD-43BE-ABDF-6C279F4C0B5F keerthi



Plz帮我解决这个问题



谢谢

解决方案

首先,我建议阅读有关几种连接方式的文章: SQL连接的可视化表示 [ ^ ]



其次,你需要创建像这样的存储过程:

 创建 程序 GetUseById 
@ usid VARCHAR 50 ) ,
@ poid VARCHAR 50 ),
@ stat VARCHAR 50
AS
BEGIN

SELECT SharedUserId,CONCAT( COALESCE (U.FirstName,' '),' ' COALESCE (U.LastName,' ')) as 名称
FROM UserPointDetails UD INNER JOIN 用户U ON UD.SharedUserId = U.UserId
WHERE pointid = @ poid AND UD.UserId=@usid AND sharedStatus = @ stat

END


Hi friends,
I need to display a tree node in UI page.. for that need to write a query to retrieve the data in SQL server.. i tried in many ways but not solved.

we are passing userid and selecting the data..we need to pass selected user id and we need to get the data in a single sp...It's Chain Process

select SharedUserId,isnull(U.FirstName,'')+' '+ISNULL(U.LastName,'') as Name
from UserPointDetails UD,Users U where pointid='E9C6E263-632E-469F-99EC-0115E827310A'
and UD.UserId='ED302157-2CAD-43BE-ABDF-6C279F4C0B5F' and UD.SharedUserId=U.UserId
and sharedStatus='Visible' and UD.SharedUserId!=UD.UserId


Result

SharedUserId Name
4A0DDF0B-2F7A-480F-B3EA-ED3D052D2B97 Ramesh
847F6D81-4985-4A10-995E-B7700E776C83 Rajesh

select SharedUserId,isnull(U.FirstName,'')+' '+ISNULL(U.LastName,'') as Name
from UserPointDetails UD,Users U where pointid='E9C6E263-632E-469F-99EC-0115E827310A'
and UD.UserId='4A0DDF0B-2F7A-480F-B3EA-ED3D052D2B97' and UD.SharedUserId=U.UserId
and sharedStatus='Visible' and UD.SharedUserId!=UD.UserId


Result
SharedUserId Name
ED302157-2CAD-43BE-ABDF-6C279F4C0B5F keerthi

Plz help me to solve this issue

Thanks

解决方案

First of all, i'd suggest to read article about several ways of joins: Visual Representation of SQL Joins[^]

Secondly, you need to create stored procedure like this:

CREATE PROCEDURE GetUseById
    @usid VARCHAR(50), 
    @poid VARCHAR(50),
    @stat VARCHAR(50)
AS
BEGIN

    SELECT SharedUserId, CONCAT(COALESCE(U.FirstName,''), ' ', COALESCE(U.LastName,'')) as Name
    FROM UserPointDetails UD INNER JOIN Users U ON UD.SharedUserId=U.UserId
    WHERE pointid=@poid AND UD.UserId=@usid AND sharedStatus=@stat

END


这篇关于sql server和wcf服务中select语句中的树节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆