Click here to Skip to main content
11,578,739 members (67,203 online)
Rate this: bad
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 10:23am
Maciej Los at 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 at 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
0 Peter Leow 135
1 Frankie-C 115
2 OriginalGriff 113
3 Richard MacCutchan 85
4 Afzaal Ahmad Zeeshan 85
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2015
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