当用户上传文档然后将文档保存在此表中并将值设置为3意味着这是在冥想
DocID DocName UploadedDate Uploadfile DocTypeID DepID ApproveID UploadedBy UserID
36 erp system 2014-02-03 Presentation1.pptx 1 4 3 noreen 21
当导演批准/拒绝此文件时,批准更改为1例如批准
所以我想在第一个用户上传文档时显示,然后他/她查看哪些文档处于播种,批准和拒绝的文档
这是我尝试的sp
ALTER procedure [dbo].[UserIDDoc]
@UserID int
as
Select
dbo.DocumentInfo.DocID as DocumentID,
dbo.DocumentInfo.DocName as DocumentName,
dbo.DocumentInfo.UploadedDate as UploadedDate,
dbo.DocType.DocType as Document,
dbo.Department.DepType as Department,
dbo.DocumentInfo.Uploadfile as FileUploaded,
dbo.ApproveType.ApproveType AS Status
FROM
dbo.DocumentInfo
inner JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
inner JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID
left join dbo.ApproveType on dbo.DocumentInfo.ApproveID=dbo.ApproveType.ApproveID
INNER JOIN dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID
where UserID=@UserID AND dbo.Approval.DesigID = 3
但是当我执行这个sp时它会像我这样显示
DocumentID DocumentName UploadedDate Document Department FileUploaded Status
36 ERP SYSTEM 2014-01-20 MSWord Computer Science system admin first assignment.docx Pending
36 ERP SYSTEM 2014-01-20 MSWord Computer Science system admin first assignment.docx Pending
36 ERP SYSTEM 2014-01-20 MSWord Computer Science system admin first assignment.docx Pending
39 def 2014-01-22 MSWord Human Resource BISE RAWALPINDI.docx Approve
但我想要这个
DocumentID DocumentName UploadedDate Document Department FileUploaded Status
36 ERP SYSTEM 2014-01-20 MSWord Computer Science system admin first assignment.docx Pending
39 def 2014-01-22 MSWord Human Resource BISE RAWALPINDI.docx Approve
答案 0 :(得分:0)
尝试添加DISTINCT关键字
Select DISTINCT
dbo.DocumentInfo.DocID as DocumentID,
dbo.DocumentInfo.DocName as DocumentName,
dbo.DocumentInfo.UploadedDate as UploadedDate,
dbo.DocType.DocType as Document,
dbo.Department.DepType as Department,
dbo.DocumentInfo.Uploadfile as FileUploaded,
dbo.ApproveType.ApproveType AS Status
FROM dbo.DocumentInfo
inner JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
inner JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID
left join dbo.ApproveType on dbo.DocumentInfo.ApproveID=dbo.ApproveType.ApproveID
INNER JOIN dbo.Approval ON dbo.DocumentInfo.DocID = dbo.Approval.DocID
where UserID=@UserID AND dbo.Approval.DesigID = 3
答案 1 :(得分:0)