Hi.

On Mon, Oct 01, 2001 at 12:37:58AM +0800, [EMAIL PROTECTED] wrote:
> On Sun, Sep 30, 2001 at 11:07:37AM -0500, Gunter Leeb wrote:
> > Hi,
> > 
> > Consider Name LIKE 'ABC%' finds all names that start with ABC.
> > 
> > I am looking for the reverse: I have a string and I am looking for
> > all the records that have a name which is the BEGINNING of this
> > string. As an example: I have 'ABCDE' and I want rows contains
> > 'ABCD' or 'ABC' or just 'A' found.
[...]
> 
> untested: SELECT * FROM <table> WHERE <column> LIKE A[<range>] 

If I understand you correctly, that would also return "AAAA" which is
not the wanted result.

SELECT * FROM <table> WHERE 'ABCDE' LIKE CONCAT(Name,'%')

should do. It takes each row, appends the joker and tries to match it
against the given value. This returns a row for

'ABCDE' LIKE 'ABC%'

but not for

'ABCDE' LIKE 'AAA%'

But note that this cannot use an index and therefore might be too
slow.

Bye,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
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