本文介绍了如何编写此嵌套的sql server语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道如何编写一个sql语句来做到这一点:

Hi,

I want to know how to write one sql statement to do like that:

select CommentID,AAA,CommentAddress  from Comments
where
AAA = select count(CommentSpamID) from CommentSpams where CommentID= CommentID



注意:
第一个语句中CommentID的值,我将在第二个语句中使用它.
希望你能理解我.

谢谢……



Notes:
the value of CommentID in first statement i will use it in second statement.
I hope you understand me .

thanks......

推荐答案

select c.CommentID,c.AAA,c.CommentAddress
from Comments c
WHERE c.AAA = (select count(cs.CommentSpamID) from CommentSpams cs where cs.CommentID= c.CommentID)



希望这会有所帮助.

如果可以解决您的问题,请接受此作为答案.



Hope this will help.

Please accept this as answer if this solves your problem.


select CommentID,(select count(CommentSpamID) from CommentSpams where Comments.CommentID= CommentSpams.CommentID) as CommentSpamNum ,CommentAddress from Comments


这篇关于如何编写此嵌套的sql server语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 23:08