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 Select Query to fetch Count of two columns fro

Author  Topic 

padmaneha
Starting Member

1 Post

Posted - 2008-09-17 : 07:51:57
I have created two tables like one is 'Food table' and the other one is the 'Videos' table

Columns which I have created in 'Food' table are 'foodid' ,'dishname' and 'blogcid'
colcumns which I have created in 'Videos' table are 'videoid, 'destid', 'videotitle'

Common column for the above two tables are foodid and destid which has the same content id for inner join

I need to fetch records of those foodids which has got blogs and videos

For example

Food id dishname blog cid
3 paneer pakora 12356
9 aloo gobhi 15265
15 chinese chickensalad 18963
19 Chicken 0
13 Tomato soup 22156

videoid videotitle destid
9 paneerpakora.fls 3
11 aloogobhi.fls 9
16 chinese chickensalad.fls 15
45 Chicken.fls 19
0 tomato soup.FLS 13

From the above data I have to fetch only those records which has blogs and videos. In other words I need a select query to fetch records of those dishes alone which has blogs >0 and destid >0 which means that fetched foodids should have both blogs and videos it should fetch records which doesnt have blogs or videos.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-17 : 08:01:05
may be this
select *
from Food f
join Videos v
on v.destid=f.foodid
where f.blog>0
Go to Top of Page
   

- Advertisement -