Thank you Chris for your answer. On 9/19/07, Chris Sansom <[EMAIL PROTECTED]> wrote: > > Well I'm hardly the world's greatest expert, but I'm curious as to > why you're always separating '%' from 'johnie' with a space, because > that way it will only find Johnie if he has a space before or after > him or both. As commented to Michael, I want to match 'johnie' and not 'johnies' or 'aljohnier'.
> > Hmmm... and why the double parentheses? In fact, why any parentheses at all? You're right. I copied&pasted another more complicated query and didn't remove parentheses. > > This oughta do it: > > SELECT friends.id FROM friends WHERE friends.firstname LIKE '%johnie%' ORDER > BY > friends.firstname LIMIT 0, 9999 > > That should find 'johnie' or 'Johnie' with absolutely any characters > before and/or after him. > > ... and if you want to simplify your queries as much as possible you > don't need to specify the table every time unless ambiguities might > arise (which they only will if there's more than one table involved), > so try: > > SELECT id FROM friends WHERE firstname LIKE '%johnie%' ORDER BY > firstname LIMIT 0, 9999 Yes, you're right, but they're more tables in my 'more-complicated' query and I forgot remove them. > > ... and unless you've really got more than 9999 friends that limit > clause is redundant too. :-) Yes, you're also right :-) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]