CREATE PROCEDURE uspSelectAddressContent
@TopicID int
AS
select TopicAddress,TopicContent from Topics where Topics.TopicID=@TopicID
select count(FavoriteID) as BookmarkNum from Favorites where TopicID=@TopicID
GO
If I interperated correctly then You want the result with columns
1 - TopicAddress
2 - TopicContent
3 - BookMarkNumber (of the topic with TopicID=@topicID From Favourite Table)
For this particular Question you can use Sub Query
CREATE PROCEDURE uspSelectAddressContent
@TopicID int
AS
select TopicAddress,TopicContent,
(select count(FavoriteID) from Favorites where Favorites.TopicID=Topics.TopicID) as BookmarkNum
from Topics where Topics.TopicID=@TopicID
GO;
For eaxmple This Query can be used to get all the topics with total Bookmarks (thats why the condition "Favorites.TopicID=Topics.TopicID" )
select TopicAddress,TopicContent,
(select count(FavoriteID) from Favorites where Favorites.TopicID=Topics.TopicID) as BookmarkNum
from Topics
GO;