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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 query

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-06-29 : 10:00:26
i have 2 tables:

tbl1: calendar

calendar_id calendar_name organization location financialyear
1 aaa lts bangalore 2010
2 bbb lts chennai 2010
3 ccc lts bangalore 2011
4 ddd rts bangalore 2010
5 eee rts bangalore 2011


tbl2: holidays

holiday_id calendar_id holidays date
1 1 new year 01-01-2010
2 1 valentine day 14-02-2010
3 2 pongal 14-01-2010
4 3 newyear 01-01-2011
5 4 may day 01-05-2010
6 5 deepavali 20-10-2011

like that

now in front end, there is

organization:dropdownlist

location:dropdownlist

year:dropdownlist

3 input fields are there,
1) organization is dropdownlist which shows all organization(coming from organization tables), the user will select one organization

2)based on selected organization, the location(coming from location table) should be filtered
for example in above sample table, if organization selected =lts means, in location dropdownlist only bangalore and chennai should come in the dropdwon list

3) if they selected location: bangalore means,
the financial year(coming from year table)only 2010,2011 based on the location only should come in drowdown list

4) Based on the organization,location,financial year, the holidays should be displayed


like below:

organization: lts
location: bangalore
year:2010

output:

holiday date
new year 01-01-2010


like that result should come?

pls help me in query to achieve this or in stored procedure.

thanks in advance

mohd.taheri
Starting Member

5 Posts

Posted - 2010-06-30 : 08:48:39
I cant understand it clean but maybe you need a simple join on your two tables on the calendar_id Columns

Select *
From calendar inner join holidays on calendar.calendar_id = holidays.calendar_id
where organization = @organization and location = @location and financialyear = @year

Regards
Go to Top of Page

mohd.taheri
Starting Member

5 Posts

Posted - 2010-06-30 : 08:55:53
I cant understand it clean but maybe you need a simple join on your two tables on the calendar_id Columns

Select *
From calendar inner join holidays on calendar.calendar_id = holidays.calendar_id
where organization = @organization and location = @location and financialyear = @year

Regards
Go to Top of Page
   

- Advertisement -