I have this procedure below that helps those in category A Admin to see their posts , with the query below if
Admin Sky and Admin Blue is connected to each other in Category A group admin they will be seeing each others post.
A CATEGORY
--------------------------
ALTER PROC [dbo].[GetUserPOSTS]
@UserName VARCHAR (200)
AS
BEGIN
SELECT profile.Name,profile.ImageName,profile.UserName,profile.UserVerifyStatus,
post.Id,post.UserName,post.FriendUserName,post.ContentPost,post.Comments,post.FImageName,post.ImageName1,post.SendDate,
post.TotalCount,post.Path
FROM USERPost post
INNER JOIN User3 profile ON profile.UserName = post.USERNAME,subb.USERNAME
WHERE post.USERNAME IN (
SELECT uf.UserName FROM FollowStatus uf
WHERE uf.UserName = @UserName AND uf.UserStatus = 'true'
UNION
SELECT uf.FriendUserName FROM FollowStatus uf
WHERE uf.UserName = @UserName AND uf.UserStatus = 'true'
UNION
SELECT post.UserName FROM User3 post
WHERE post.UserName = @UserName
)
ORDER BY post.Id DESC
END
CATEGORY B SUB
--------------------------------------------------
Now here is SUB catgory B Adim account here admins who are connected together will be seeing each others post
ALTER PROC [dbo].[GetUserPOSTSSUB]
@UserName VARCHAR (200)
AS
BEGIN
SELECT profilesub.Name,profilesub.ImageName,profilesub.UserName,profilesub.UserVerifyStatus,
subpost.UserName,subpost.ContentPost
FROM SUBGROUPSpost subpost
INNER JOIN User3 profilesub ON profilesub.UserName = subpost.USERNAME
WHERE subpost.USERNAME IN (
SELECT sub.FriendUserName FROM Subgroups sub
WHERE sub.UserName = @UserName AND sub.UserStatus = 'true'
UNION
SELECT subpost.UserName FROM User3 subpost
WHERE subpost.UserName = @UserName
)
ORDER BY subpost.Id DESC
END
-----------------------------------
3rd stage join all
Here i want to bring the two scripts on one procedure script so that the posts from the two categories can appear on one Datalist
on page
ALTER PROC [dbo].[GetUserPOSTS]
@UserName VARCHAR (200)
AS
BEGIN
SELECT profile.Name,profile.ImageName,profile.UserName,profile.UserVerifyStatus,
profilesub.Name,profilesub.ImageName,profilesub.UserName,profilesub.UserVerifyStatus,
subpost.UserName,subpost.ContentPost
post.Id,post.UserName,post.FriendUserName,post.ContentPost,post.Comments,post.FImageName,post.ImageName1,post.SendDate,
post.TotalCount,post.Path
FROM USERPost post
INNER JOIN User3 profile ON profile.UserName = post.USERNAME,subpost.USERNAME
WHERE post.USERNAME IN (
SELECT uf.UserName FROM FollowStatus uf
WHERE uf.UserName = @UserName AND uf.UserStatus = 'true'
UNION
SELECT uf.FriendUserName FROM FollowStatus uf
WHERE uf.UserName = @UserName AND uf.UserStatus = 'true'
UNION
SELECT post.UserName FROM User3 post
WHERE post.UserName = @UserName
)
ORDER BY post.Id DESC
END
So far am stuck on this 3rd stage, any help