Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Applying grouping filter to sql query from dropdown

Posted on 2009-07-07
3
Medium Priority
?
206 Views
Last Modified: 2013-11-08
Below is some ASP code that lets me search through patient data.  I also can apply filters (date of service, department, etc.).  The one that's giving me trouble is the one for "location".

There's 3 different sites, but within each site there's sub locations.  Example, BIHP-IO and BMHP-IO would belong to BH (among others).  You can see the details in the case statement.

SELECT CASE Location WHEN 'BIHP-OT' THEN 'BH' WHEN 'BIHP-H' THEN 'BH'  WHEN 'EMHP-OF' THEN 'EC'...and so on.

How can I search by location and make (for example) BIHP-OT and BIHP-H come up when I select BH from the drop down?  Right now it's sending the "BH" as the filter, and that's not a real location.

My complete code is attached.
<tr>
		<td>Location</td>
		<td>
			<select id="location" name='location'>
				<%
				If varSearchLoc <> "" then
					Response.Write("<option value='" & varSearchLoc & "'>" & varSearchLoc & "</option>")
					Response.Write("<option value=''>--Choose--</option>")
				Else
					Response.Write("<option value=''>--Choose--</option>")
				End If
				%>
				<option value='BH'>BH</option>
				<option value='EC'>EC</option>
				<option value='HD'>HD</option>
			</select>
		</td>
	</tr>

Open in new window

code.txt
0
Comment
Question by:IntercareSupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
rg20 earned 2000 total points
ID: 24798411
I would try a nested query

strlocationsearch = "select * from table where location_table in (select sublocation from location_table where location = " & varSearchLoc  &" )"

Query may need work
0
 
LVL 1

Expert Comment

by:dannocracker
ID: 24798412
If I understand your question, you might want to have two DDLs, one dependent on the other. The 2nd one is populated during run time when a selection is made in the 1st one. If this is correct, let me know and I'll provide more specifics with a code example.
0
 

Author Closing Comment

by:IntercareSupport
ID: 31600795
Thanks!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question