Solved

Applying grouping filter to sql query from dropdown

Posted on 2009-07-07
3
195 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
3 Comments
 
LVL 9

Accepted Solution

by:
rg20 earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now