Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Looks like bit tricky query
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kolucoms6
Average Member

845 Posts

Posted - 16 September 2007 :  10:34:40  Show Profile


Purpose :
**************
To display List of Non-DNC states in a dropdown based on particular campaign.

I have 2 tables.
1) StateMaster : Contains StateID, StateCode, Statename
2) DNCState : Contains DNCStateID,StateID,CampaignID

Now, when I select a particular Campaign from a DropDown , I want to display records form Statemaster but not those records which are there in DNCState.

Suggestion ?

What I tried :
****************

1) Get List of Campaigns
2) Loop through above Campaign List
3) Run query :

SELECT StateList.*, DNCState.CampaignID FROM DNCState RIGHT JOIN StateList ON DNCState.StateID = StateList.StateID WHERE DNCState.CampaignID Is Null OR DNCState.CampaignID<> " & CampaignID

4) Loop through above query.
5) Create one Drop Down select an fill values.

Problem:
**********
Not getting things correctly. :-(

kolucoms6
Average Member

845 Posts

Posted - 16 September 2007 :  11:20:51  Show Profile
Few entried from DB:

1) CampaignMaster:

CampaignID CampaignName
9 PVC Travel
10 NHN

2) DNCState

DNCStAteID CampaignID StateID
2 10 2
3 10 9
4 10 11
5 9 2

3) StateList

StateID StateCode StateName
1 AL Alabama
2 AK Alaska
3 AZ Arizona
4 AR Arkansas
5 CA California
6 CO Colorado
7 CT Connecticut
8 DE Delaware
9 FL Florida
10 GA Georgia
11 HI Hawaii
12 ID Idaho
13 IL Illinois
14 IN Indiana
15 IA Iowa

Go to Top of Page

gary b
Junior Member

USA
267 Posts

Posted - 18 September 2007 :  14:31:41  Show Profile  Visit gary b's Homepage
quote:
Originally posted by kolucoms6

I have 2 tables.
1) StateMaster : Contains StateID, StateCode, Statename
2) DNCState : Contains DNCStateID,StateID,CampaignID

Now, when I select a particular Campaign from a DropDown , I want to display records form Statemaster but not those records which are there in DNCState.

SELECT StateList.*, DNCState.CampaignID FROM DNCState RIGHT JOIN StateList ON DNCState.StateID = StateList.StateID WHERE DNCState.CampaignID Is Null OR DNCState.CampaignID<> " & CampaignID



As far as I can see, StateList is not one of your tables. Also appears that DNCState is a sub-table of StateMaster. I'm thinking the relationship is incorrect for what you want to display. But I've been wrong before!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 1.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07