473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sub Query for fetching records - Urgent Please

I executed the below query for getting the details of dishes which are tagged to the festival 'Durga Pooja'

select fg.tagname, fg.foodid, f.dishes, f.dishtype
from foodtag fg inner join food f
on fg.foodid = f.contentid
where tagname='Navratri / Durga Puja' and isapproved=1
order by foodid

Result is displayed as fetching some 167 records approximately

Festival tagname foodid dishes dishtype
Navratri / Durga Puja 1 Aloo Chat Punjabi Veg
Navratri / Durga Puja 30 Payasam South Indian Veg
Navratri / Durga Puja 62 Almond Kheer Veg
Navratri / Durga Puja 68 Aloo Tikki Punjabi Veg

I need to execute another query which will give the number of recipes posted for the above dishes for which I wrote a query as

select f.dishes,f.contentid,f.titleurl,count(f.dishes)as Dishescount
from food f left join foodmemberpref fmp
on f.contentid=fmp.foodid where isapproved=1 and blogcid>0
and f.contentid in(1,30,62,68)

Result is dispalyed as
Dishes contentid titleurl RecipesCnt
Aloo Chat 1 punjabi/aloo-chat 1
Payasam 30 south-indian/payasam 5
Aloo Tikki 68 punjabi/aloo-tikki 7

I need a subquery which can be written as single query to fetch records of those dishes which are tagged to Durga pooja festival and the recipes posted for these durga pooja dishes. It should also display the details of the dishes which has zero recipes. In other words, it should display all those records of 'Durga Pooja' and the corresponding recipe count displaying the dish details even though, it has got zero recipes, but tagged to durga pooja

Output should be displayed as

Festival tagname foodid dishes dishtype Recipescnt
Navratri / Durga Puja 1 Aloo Chat Punjabi Veg 1
Navratri / Durga Puja 30 Payasam South Indian Veg 5
Navratri / Durga Puja 62 Almond Kheer Veg 0
Navratri / Durga Puja 68 Aloo Tikki Punjabi Veg 7
Sep 23 '08 #1
1 1564
deepuv04
227 Expert 100+
Hi,
try the following query. If this doesnt work plz kindly post some sample data.

Expand|Select|Wrap|Line Numbers
  1.  
  2. select    fg.tagname, fg.foodid, f.dishes, f.dishtype,count(f.contentid) as Dishescount
  3. from    foodtag fg inner join 
  4.         food f on fg.foodid = f.contentid left outer join
  5.         foodmemberpref fmp on f.contentid=fmp.foodid          
  6. where    tagname='Navratri / Durga Puja' and isapproved=1 and blogcid>0
  7. group by fg.tagname, fg.foodid, f.dishes, f.dishtype
  8. order by fg.foodid 
  9.  
thanks
Sep 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: chriskoch | last post by:
I am running a DTS Package. I have a temp table with 1494 records. I am inserting a 'Y' or 'N'into a temp table #HasClaims. The TempTable name with the Provider Id's(PRPR_ID) is...
2
by: bhargav.desai | last post by:
Hello ACCESS gurus! Can someone help me out here please? I have a table, company, that contains about 1.5M records, and has Company_NAME field. I have been supplied list that contains name of...
0
by: Shujun Huang | last post by:
Hi, I am working on converting Informix database to Postgre. I have one question for fetching records using PostgreSQL. The record I am fetching is a variable size text string. Before fetching...
1
by: vidyayegnaraman | last post by:
Hi, I need to find out the time taken to insert a certain number of records into a table in oracle. The insertion was not a direct insert, rather it was done through an application functionality, so...
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
30
by: SSG001 | last post by:
Hi, I'm using scriptaculous autocomplete for my text box and it works perfectly ok i have made server.php for fetching the values in the ul list and it is shown correctly on the main form but after...
2
by: Muddasir | last post by:
Hello everyone. guyz can you please help me in this query Note: i put this question in MySQL forum but no one replied. please guyz its urgent. id | name | lastname | status | hrs 1 qwe sss...
2
by: =?Utf-8?B?QVZM?= | last post by:
hi, I've a requireemnt ..in which my query will pull all the data from the database table..and binds to a grid based on some calculations..... the count of records wil be around 700000...
2
by: Bill McCormick | last post by:
Hi, I'm building a C# VS2005 project and I need an elegant way to output query results to an string array or list<Tof delimited strings. Thanks, Bill
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.