我昨天在这里问了一个问题
现在我改变了我的代码如下
declare @like bit, @dislike bit
IF EXISTS (select * from likeordislike
where comment_id = @comment_id and likevar = 1 and dislikevar = 0)
BEGIN
SET @like = 'true'
SET @dislike = 'false'
END
ELSE IF EXISTS (select * from likeordislike
where comment_id = @comment_id and likevar = 0 and dislikevar = 1)
BEGIN
SET @like = 'false'
SET @dislike = 'true'
END
ELSE
BEGIN
SET @like = 'false'
SET @dislike ='false'
END
SELECT
comment_id, comment_post_id, comment_user_id,
comment_text, comment_like, comment_dislike,
comment_reply_to_id, comment_date,
@like as begendi,
@dislike as begenmedi
FROM
comment
ORDER BY
comment_date DESC
我正在尝试选择评论和评论喜欢或不喜欢状态。
我在我的 asp.net 网页上使用数据列表。我需要每个评论的返回值。我必须提供@comment_id 参数,此查询为每个评论(begendi = 1, begenmedi = 0
)返回相同的结果。我怎么解决这个问题?
ScopeIdentity
还是需要返回值?谢谢(我有两个表 1-comment 表,2-likeordislike 表,其中包含 comment_id、user_id、likevar、dislikevar 和 eventdate 列)
select *
from likeordislike
where comment_id = @comment_id and likevar = 0 and dislikevar = 1