...

View Full Version : query help - find 10 closest



jedimastermopar
04-04-2007, 05:08 PM
Hey.
I have a table with 3 coloumns
IDnum, X and y
x and y are doubles

I need a query that will display the 10 closest cross references of the x and y values with no limiting span from the input x and y.

I want to return the IDnum's for those 10 matches.

That table has around 80,000 records in it, and is expected to see the query run against probably a few dozen times per day. Not heavy use but the performance is a must from this query.

Any ideas where to start?

jedimastermopar
04-04-2007, 05:21 PM
I think I can get it to work with a span.
eg find all x and y intersections within an x or y span of 20

not exactly sure how to do it in sql cod ebut in pseudo code something like this

Find all idnum where (x is > (xinput - 10) and x < (xinput - 10)) and (y is > (yinput - 10) and x < (yinput - 10))

Any ideas on how to write that query?

guelphdad
04-04-2007, 05:47 PM
take out the word IS and substitute variables for xinput and yinput. Also you could use BETWEEN.

jedimastermopar
04-04-2007, 07:15 PM
Yah I got that to work thanks. Sometimes you just need to ask the question to figure it out on your own >:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum