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

Reply via email to