Click here to Skip to main content
13,409,492 members (18,060 online)
Rate this:
Please Sign up or sign in to vote.
I am trying to construct a sort of "Property Search" Query for my site.

Where I am so far:
I have a multi select dropdownlist on my site that contains "Neighborhoods" within a city. I am passing the selected IDs of that dropdown to a stored proc via a comma delimited list (varchar). I am then splitting those values using a User Defined Function which give me back a simgle column called ID that contains a row for each selected value.


My Query:
I have a table that has many "Properties" These properties each reside within one of the "Areas", so each has an Area_ID. Of course many properties can belong to a category.
I need to bring back all of the properties that belong to all of the "Areas" that were selected.

Basically I am confused on how I should approach this query. Joins, Temp table, Where IN, etc.

Any help is appreciated

Posted 11-Feb-13 11:23am
Maciej Los 11-Feb-13 17:13pm
You can achieve that using: JOIN's and WHERE FieldName IN(arg1, ar2, argN) clause.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If your UDF gives you back a table..

Select xxx from Properties AS P join theUDFTable AS U on  P.Area_Id = U.AreaID
jhoward73 12-Feb-13 10:01am
Exactly what I needed and works perfectly.
Not sure why I made it so difficult.

Thanks so much _Maxxx

Here is the code I ended up with:
@delimitedlist varchar(100)
create table #AreasTemp (ID int, value int)
insert into #AreasTemp select * from f_Split_byDelimiter(@delimitedlist,',')
Select StreetAddress,area
from dbo.Properties AS P join #AreasTemp AS AT on P.area = AT.value
order by Area

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180221.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100