you'll need to write a recursive routine to call the same sql statement and iterate from the largest value and attenuate that value by 1 each time # file: test.pl been a few years but this should work #initialize your variable that you will attenuate my $global = "9876543210"; #number of rows actually returned my $affectedrows=0; #the offset for constructing the next global variable my $offset=10;
#stay in this loop until we have successful result #OR there are no rows found while($affectedrows==0) { do_it(); } if($affectedrows==99) print("no rows found"); sub do_it { # DEFINE A MySQL QUERY $myquery = "SELECT * FROM $tablename where column1=$global"; $execute = $connect->query($myquery); #attenuate 1 character off $offset = $offset -1; $global = substr($global, 0, $offset); #test for global having no value if ($offset==0) $affectedrows=99; else $affectedrows = $execute->affectedrows($myquery); } http://www.tizag.com/perlT/perlmysqlquery.php (notice the site is written in PHP) Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Tue, 3 Nov 2009 18:17:52 +0100 > From: n...@phibee.net > To: mysql@lists.mysql.com > Subject: SQL Question > > Hi > > i request a small help for know if it's possible. > > Anyone know if they have a Sql request for > search the best value at one information: > > Sample: > > i have a table with: > > ID int 5 > Chaine int 16 > > and this entry: > > 1 12345 > 2 123 > 3 12 > > > i am search a request in "WHERE" : > > Chaine LIKE '123456789' and if he don't have into the database, > he test Chaine LIKE '12345678' etc .. > and when he arrive at 12345, he sent the ID information > > thanks for your help > > (PS: i use Perl for extract data) > Jerome > Sorry for my english > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=mgai...@hotmail.com > _________________________________________________________________ Bing brings you maps, menus, and reviews organized in one place. http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1