生成的sql代码,谁帮我看一下
下面的代码怎么也弄不明白,连个表名也没有.语法检查却没问题.谁帮我解释一下大概什么意思
CREATE PROCEDURE UP_VoteEvent_Overed AS
SELECT TOP 100 PERCENT dbo.v_countVS_veid.countVS, dbo.v_total.EndTime,
dbo.v_total.BeginTime, dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name,
dbo.v_total.veid, dbo.v_uiid.uiid AS countUser
FROM dbo.v_countVS_veid INNER JOIN
dbo.v_total ON dbo.v_countVS_veid.veid = dbo.v_total.veid INNER JOIN
dbo.v_uiid ON dbo.v_total.veid = dbo.v_uiid.VEID
GROUP BY dbo.v_countVS_veid.countVS, dbo.v_total.EndTime, dbo.v_total.BeginTime,
dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name, dbo.v_total.veid,
dbo.v_uiid.uiid
ORDER BY dbo.v_total.veid DESC
GO
------解决方案--------------------SELECT TOP 100 PERCENT dbo.v_countVS_veid.countVS, dbo.v_total.EndTime,
dbo.v_total.BeginTime, dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name,
dbo.v_total.veid, dbo.v_uiid.uiid AS countUser
FROM dbo.v_countVS_veid INNER JOIN -- 三张表的连接 ---------------
dbo.v_total ON dbo.v_countVS_veid.veid = dbo.v_total.veid INNER JOIN |--- dbo.v_uiid ON dbo.v_total.veid = dbo.v_uiid.VEID ----------------
GROUP BY dbo.v_countVS_veid.countVS, dbo.v_total.EndTime, dbo.v_total.BeginTime,
dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name, dbo.v_total.veid,
dbo.v_uiid.uiid
ORDER BY dbo.v_total.veid DESC
连个表名也没有 ????
------解决方案--------------------CREATE PROCEDURE UP_VoteEvent_Overed AS ---创建存储过程UP_VoteEvent_Overed
SELECT TOP 100 PERCENT dbo.v_countVS_veid.countVS, dbo.v_total.EndTime,
--查找100%的 各列 (所有者dbo,表名v_countVS_veid 或表名v_total)
dbo.v_total.BeginTime, dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name,
dbo.v_total.veid, dbo.v_uiid.uiid AS countUser--as 别名
FROM dbo.v_countVS_veid INNER JOIN---表v_countVS_veid 内联接表dbo.v_total 条件是
dbo.v_total ON dbo.v_countVS_veid.veid = dbo.v_total.veid INNER JOIN
------dbo.v_countVS_veid.veid = dbo.v_total.veid ,然后再内联 表dbo.v_uiid
dbo.v_uiid ON dbo.v_total.veid = dbo.v_uiid.VEID
------条件是 dbo.v_total.veid = dbo.v_uiid.VEID
GROUP BY dbo.v_countVS_veid.countVS, dbo.v_total.EndTime, dbo.v_total.BeginTime,
---对上面的联合查询分组 分组依据列 (各表的一些列)
dbo.v_total.State, dbo.v_total.EventType, dbo.v_total.Name, dbo.v_total.veid,
dbo.v_uiid.uiid
ORDER BY dbo.v_total.veid DESC --按dbo.v_total.veid排序 降序(desc)
GO
------解决方案--------------------dbo.v_countVS_veid ,dbo.v_total, dbo.v_uiid 这三张就是表。这是一个最简单的存储过程。三张表两两关联。INNER JOIN用来关联表后面跟两个表的关联字段。这个存储过程的作用就是取出三个表中某些字段
------解决方案--------------------看看视图中有没有这些名字