regexp in conditional

2014-01-07 Thread Larry Martell
Can I use an regexp in a conditional? I need to do something like this:

SELECT (IF r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

I'm getting an error from that. Is there some way to do this?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: regexp in conditional

2014-01-07 Thread Michael Dykman
I think you just have a misplaced parenthesis.  try:
 SELECT IF(r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;



On Tue, Jan 7, 2014 at 2:22 PM, Larry Martell larry.mart...@gmail.comwrote:

 Can I use an regexp in a conditional? I need to do something like this:

 SELECT (IF r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

 I'm getting an error from that. Is there some way to do this?

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql




-- 
 - michael dykman
 - mdyk...@gmail.com

 May the Source be with you.


Re: regexp in conditional

2014-01-07 Thread Peter Brawley


On 2014-01-07 1:22 PM, Larry Martell wrote:

Can I use an regexp in a conditional? I need to do something like this:

SELECT (IF r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

I'm getting an error from that. Is there some way to do this?


SELECT IF( r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no' )
FROM s;


PB


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: regexp in conditional

2014-01-07 Thread Larry Martell
On Tue, Jan 7, 2014 at 12:31 PM, Peter Brawley
peter.braw...@earthlink.net wrote:

 On 2014-01-07 1:22 PM, Larry Martell wrote:

 Can I use an regexp in a conditional? I need to do something like this:

 SELECT (IF r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

 I'm getting an error from that. Is there some way to do this?


 SELECT IF( r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no' )
 FROM s;


Thanks!

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql



Re: regexp in conditional

2014-01-07 Thread Larry Martell
On Tue, Jan 7, 2014 at 12:33 PM, Michael Dykman mdyk...@gmail.com wrote:
 I think you just have a misplaced parenthesis.  try:
  SELECT IF(r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

Yes, thanks!




 On Tue, Jan 7, 2014 at 2:22 PM, Larry Martell larry.mart...@gmail.comwrote:

 Can I use an regexp in a conditional? I need to do something like this:

 SELECT (IF r REGEXP '^ED[HMUZ][0-9]$', 'yes', 'no') FROM s;

 I'm getting an error from that. Is there some way to do this?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql