You are putting a space between "johnie" and the % wildcards. That space is not ignored, it is part of the pattern. LIKE "%johnie%" will find every occurrence of "johnie" no matter what surrounds it.
If you need something more complicated, such as only ignoring "(", then you need to get more complicated. You might even need a regular expression. Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com www.giiexpress.com www.etudes-marche.com > -----Original Message----- > From: thomas Armstrong [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 19, 2007 1:35 PM > To: mysql@lists.mysql.com > Subject: Query to find "foo" within "(foo)" > > Hi. > > I've got this table in mySQL: > > item 1: > -- firstname: John (Johnie) > -- phone: 555-600-200 > > item 2: > -- firstname: Peter > -- phone: 555-300-400 > > I created this SQL query to find 'johnie': > ------------------------ > SELECT friends.id FROM friends WHERE ((friends.firstname LIKE '% > johnie %' OR friends.firstname LIKE 'johnie %' OR friends.firstname > LIKE '% johnie' OR friends.firstname LIKE 'johnie' OR friends.phone > LIKE '% johnie %' OR friends.phone LIKE 'johnie %' OR friends.phone > LIKE '% johnie' OR friends.phone LIKE 'johnie')) ORDER BY > friends.firstname LIMIT 0, 9999 > ------------------------ > > But it doesn't match anything, because it's considers "(johnie)" as a > single word. Is there any way to make mySQL consider "(johnie)" as > "johnie". > > I know I can create another condition within my query: > firstname LIKE '(johnie)' OR firstname LIKE '(johnie%' OR firstname > LIKE '%johnie)' > but I also might consider other characters like ' " - * > > Any suggestion? > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]