mysql - How to get near value from range in php -


how find nearest value mysql database table of give value, want is:

case1: if giving input 2500 pincode retrieving record corresponding pincode value database.

case2: if record not exits entered pincode(2500) , have nearest value of 2500 , corresponding records too.

stored procedure calling case1 sp_findlocation('xxxxxxxx','2500',@addresss)

delimiter $$ use `test`$$ drop procedure if exists `sp_findlocation`$$ create procedure `sp_findlocation`(in mobile varchar(20),in pincode varchar(20),out address varchar(100)) begin        if(pincode not null , pincode!= '')         set @c1 = '';         set @c2 = '';         set @c3 = '';         set @qry='select locality,store_name,contact_number @c1,@c2,@c3 test_upload pin=? limit 1';         prepare stmt @qry;         set @c = pincode;         execute stmt using @c;         deallocate prepare stmt;         if(@c1!='' || @c2!=''||@c3!='')                 set address= concat(@c1, '|',@c2,'|',@c3);               else             set address= "no result";         end if;      else             set address="please enter valid pin code";     end if;  end$$ delimiter ; 

what geting records including case2?


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -