Click here to Skip to main content
15,886,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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


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

thanks......
Posted
Updated 25-Dec-10 20:42pm
v3

Hi,

You can re-wright the sql statement like the following,

SQL
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.
 
Share this answer
 
v2
Comments
MrLonely_2 26-Dec-10 4:23am    
No, it is NOT solve it man,....the problem stilllllll
Shahriar Iqbal Chowdhury/Galib 26-Dec-10 4:48am    
what error do u see?
Thanks god , :)

I solved it.

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900