I am going to build an app similar to twitter. I have three tables. user, userprofile and followers.
user -> id, username, email, password, active
userprofile -> id, userid, firstname, middlename, lastname, dob
followers-> id, userid, followingid
I wrote the below sql to search users. It also needs to return whether the logged in user is following the search result users.
But this didn't worked.Please help. Thanks in advance.
user -> id, username, email, password, active
userprofile -> id, userid, firstname, middlename, lastname, dob
followers-> id, userid, followingid
I wrote the below sql to search users. It also needs to return whether the logged in user is following the search result users.
ALTER PROCEDURE [dbo].[sp_User_Search] @q nvarchar(250), @userid uniqueidentifier AS BEGIN DECLARE @p nvarchar(250) set @p = '%' + @q + '%' SELECT username,firstname,middlename,lastname,followingid FROM [dbo].[user] LEFT OUTER JOIN [dbo].[userprofile] ON [dbo].[user].id = [dbo].[userprofile].userid LEFT OUTER JOIN [dbo].[followers] ON [dbo].[user].id = [dbo].[followers].followingid WHERE (username like @p or firstname like @p or middlename like @p or lastname like @p ) AND [dbo].[followers].userid = @userid END
But this didn't worked.Please help. Thanks in advance.