Something like:

SET @version = "6.0";
SELECT CASE direction WHEN '>' THEN IF( @version > version, 'Y', 'N') WHEN '<' 
THEN IF (@version < version, 'Y','N)  ... END AS operation FROM test;

-----Original Message-----
From: Matt Neimeyer [mailto:m...@neimeyer.org]
Sent: Wednesday, July 08, 2009 2:45 PM
To: mysql@lists.mysql.com
Subject: CONCAT with IF?

I want to store the product version that an article applies to and a
comparison operator in my news system. But I can't wrap my head around
the where clause...

Here's what I've tried...

CREATE TABLE test (version char(10), direction char(2));

select concat("6.0",direction,version) as operation from test;

+---------+
|operation|
+---------+
| 6.0=6.0
| 6.0>=6.0
| 6.0<6.1
| 6.0>6.2
+---------+

But when I do select if(concat("6.0",direction,version),"Y","N") from
test I ALWAYS get "Y"... which means I wouldn't get any meaningful
results if I used it in a where clause...

Any ideas on ways I can do this?

Thanks!

Matt

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=gto...@ffn.com


The information contained in this transmission may contain privileged and 
confidential information. It is intended only for the use of the person(s) 
named above. If you are not the intended recipient, you are hereby notified 
that any review, dissemination, distribution or duplication of this 
communication is strictly prohibited. If you are not the intended recipient, 
please contact the sender by reply email and destroy all copies of the original 
message.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to