RE: BETWEEN... LIKE query
Why you don't try: BETWEEN '$surname_from' AND concat($surname_to,'z') ? Makis > -Original Message- > From: Craig Shepherd [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, March 05, 2002 1:30 PM > To: [EMAIL PROTECTED] > Subject: BETWEEN... LIKE query > > > Hi, > > I have a form with two fields surname_from and surname_to, I > want to be able > to do a select query where the results will lie between these > to values. > That's easy enough but I also want to include all results > where the record > field (surname) matches the first part of the fields - in > effect a BETWEEN > query incorporating the LIKE function. > > For example > > select * from consumers surname BETWEEN '$surname_from' AND > '$surname_to' > > assume $surname_from = A and $surname_to = B > > would only return results where the surname is A or greater > but less than B, > but I would like to include all records where records also > start with B. > > For example it would return > > A > Allan > Anderson > Appleby > B > > But I want it to return > > A > Allan > Anderson > Appleby > B > Black > Brown > Butterworth > > Has anyone any ideas? > > Thanks in anticipation > > Craig Shepherd > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: BETWEEN... LIKE query
So if I did something like $temp = $surname_from."{"; select * from consumers surname BETWEEN '$surname_from' AND '$temp' it should do the trick? > -Original Message- > From: Roger Baklund [mailto:[EMAIL PROTECTED]] > Sent: 05 March 2002 11:49 > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: RE: BETWEEN... LIKE query > > > * Craig Shepherd > > select * from consumers surname BETWEEN '$surname_from' AND > '$surname_to' > > > > assume $surname_from = A and $surname_to = B > > > > would only return results where the surname is A or greater but > > less than B, but I would like to include all records where records > > also start with B. > > Append a high ascii value to the $surname_to, like '{', so that your query > will be: > > select * from consumers surname BETWEEN 'A' AND 'B{' > > -- > Roger > > > - > Before posting, please check: >http://www.mysql.com/manual.php (the manual) >http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: BETWEEN... LIKE query
* Craig Shepherd > select * from consumers surname BETWEEN '$surname_from' AND '$surname_to' > > assume $surname_from = A and $surname_to = B > > would only return results where the surname is A or greater but > less than B, but I would like to include all records where records > also start with B. Append a high ascii value to the $surname_to, like '{', so that your query will be: select * from consumers surname BETWEEN 'A' AND 'B{' -- Roger - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
BETWEEN... LIKE query
Hi, I have a form with two fields surname_from and surname_to, I want to be able to do a select query where the results will lie between these to values. That's easy enough but I also want to include all results where the record field (surname) matches the first part of the fields - in effect a BETWEEN query incorporating the LIKE function. For example select * from consumers surname BETWEEN '$surname_from' AND '$surname_to' assume $surname_from = A and $surname_to = B would only return results where the surname is A or greater but less than B, but I would like to include all records where records also start with B. For example it would return A Allan Anderson Appleby B But I want it to return A Allan Anderson Appleby B Black Brown Butterworth Has anyone any ideas? Thanks in anticipation Craig Shepherd - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php