Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Profile

Author  Topic 

mcupryk
Yak Posting Veteran

91 Posts

Posted - 2011-01-25 : 18:12:49
ALTER

PROCEDURE [dbo].[prc_ProfileViews_SelectByUserName]
(

@ViewedUsernameID int,

@FromDate DATETIME = NULL
)

AS

SELECT

TOP 100

XXXXX.ViewedUserNameID as ViewedUserNameID, ---> need to join this with table PK tbl_profile on ProfileID = PK ViewedUserNameID on tbl_ProfileViews

a.ProfileID as ProfileID,

a.UserName as UserName,

a.FirstName as FirstName,

a.LastName as LastName,

a.HeadLine as HeadLine,

a.EmailAddress as EmailAddress,

a.GenderID as Gender,

b.Gender as GenderName,

a.SeekingID as Seeking,

c.Seeking as SeekingName,

a.SearchAgeStartID as StartAge,

--------------------------------------------------------------------------------------------

ALTER PROCEDURE [dbo].[prc_ProfileViews_SelectByUserName]
(
@ViewedUsernameID int,
@FromDate DATETIME = NULL
)
AS
SELECT TOP 100
A.[UserNameID] as ViewerUserNameID, ----- table tbl_ProfileViews
A.[ViewUserNameID] as ViewedUserNameID, ----- table tbl_ProfileViews
A.[TimeStamp] as ViewedDate, ----- table tbl_ProfileViews
B.[PhotoID], ----- table tbl_Photos
B.[ProfileID], ----- table tbl_Photos
B.[p_Primary] ----- table tbl_Photos
FROM tbl_ProfileViews A INNER JOIN tbl_Photos B
ON A.UserNameID = B.ProfileID
WHERE A.ViewUserNameID = @ViewedUsernameID AND B.[p_Primary] = '1'
AND A.[TimeStamp] = (SELECT MAX(C.[TimeStamp])
from tbl_ProfileViews C Where C.ViewUserNameID = @ViewedUsernameID)
ORDER BY A.[TimeStamp] DESC

Need to join tbl_Profiles to get
XXXXX.ViewedUserNameID as ViewedUserNameID, ---> need to join this with table PK tbl_profile on ProfileID = PK ViewedUserNameID on tbl_ProfileViews

a.ProfileID as ProfileID,

a.UserName as UserName,

a.FirstName as FirstName,

a.LastName as LastName,

a.HeadLine as HeadLine,

a.EmailAddress as EmailAddress,

a.GenderID as Gender,

b.Gender as GenderName,

a.SeekingID as Seeking,

c.Seeking as SeekingName,

a.SearchAgeStartID as StartAge,

Any help would be awesome.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-26 : 10:57:18
sorry very difficult to determine from query what you're looking at. please post some sample data along with table strucutures and then explain what you want

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -