Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Query to find "foo" within "(foo)"

From: Baron Schwartz <baron(at)xaprb.com>
Date: Thu Sep 20 2007 - 07:11:43 EDT


thomas Armstrong wrote:

>> If you need something more complicated, such as only ignoring "(", then you
>> need to get more complicated. You might even need a regular expression.

> I'm to browse:
> http://dev.mysql.com/doc/refman/5.0/en/regexp.html
> http://www.wellho.net/regex/mysql.html

You know, you don't have to do fancy regexp matching or even LIKE. There's really no advantage to using those over what looks like it'll be simpler in this case: INSTR().

SELECT INSTR('John (Johnie)', 'Johnie') AS John, INSTR('Peter', 'Johnie') AS Peter;
+------+-------+
| John | Peter |
+------+-------+
| 7 | 0 |
+------+-------+

Just say "WHERE INSTR(haystack, needle) > 0" in your WHERE clause, and you're done.

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Thu Sep 20 11:13:59 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:11:18 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library