Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql doubt

Author  Topic 

sasikumar
Starting Member

1 Post

Posted - 2009-01-02 : 09:11:20
consider that i have 3 tables.named as articles,information,details...
i want to count the how many information present in table where articles.information_id = anynumber... but one condition count should return information table should have atleast one details .

relations:
articles has many information
information has many details...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 09:16:09
[code]
select count(a.article_id)
from articles a
join information i
on i.information_id=a.information_id
where i.information_id=@yournumber
[/code]
where @yournumber is number passed.

Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-02 : 11:06:54
try this
select count(article_id) from articles where information_id in (Select information_id from information ) and information_id = @givennumber
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 11:18:20
quote:
Originally posted by bklr

try this
select count(article_id) from articles where information_id in (Select information_id from information ) and information_id = @givennumber


better to use exists rather than in
Go to Top of Page
   

- Advertisement -