Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-22-2004, 04:28 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
MySQL Return closest matches?

I have a column with the following values...

1
6
8
10
15
20
23
25
99
100
120

I want to search against that column and return the matches that are the closest in value to my search term.

is there any way to do this?
Admin is offline   Reply With Quote
Old 07-22-2004, 04:34 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
how many results would you like to buffer? do you want to go above and below the number?


the only way i can think of is 2 queries.
Code:
select * from table where field>=$number order by field asc limit 5;
select * from table where field<$number order by field desc limit 5;
eh?
__________________
Mike
sde is offline   Reply With Quote
Old 07-22-2004, 04:40 PM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
i would prefer to get the 4 that are closest to my search number, but i think doing it that way will work for now.

thanks sde.

lets wakeboard.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 07-22-2004, 04:43 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
cool, .. tell me when, i'll be there. my friend in murrieta just got a tower for his boat too.
__________________
Mike
sde is offline   Reply With Quote
Old 07-22-2004, 04:45 PM   #5 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
we are gonna head to my parents place in blythe for some river time next weekend. they don't have a boat out there, but we are gonna try to ride behind the seadoos. email me if you think you can go..
Admin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenGL.dll Mr.Anderson Platform/API C++ 3 08-13-2004 11:07 AM
and on to mysql .. sde Linux / BSD / OS X 2 01-18-2003 08:39 PM
MySQL problems sde Linux / BSD / OS X 5 12-07-2002 11:04 PM


All times are GMT -8. The time now is 10:19 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting