CONCAT with IF?

CONCAT with IF?

am 08.07.2009 23:44:38 von Matt Neimeyer

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=gcdmg-mysql-2@m.gmane.org

RE: CONCAT with IF?

am 09.07.2009 01:37:48 von Gavin Towey

Something like:

SET @version =3D "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:matt@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=3D6.0
| 6.0>=3D6.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=3Dgtowey@ffn.com


The information contained in this transmission may contain privileged and c=
onfidential information. It is intended only for the use of the person(s) n=
amed above. If you are not the intended recipient, you are hereby notified =
that any review, dissemination, distribution or duplication of this communi=
cation is strictly prohibited. If you are not the intended recipient, pleas=
e 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=3Dgcdmg-mysql-2@m.gmane.o rg