spoowiz
asked on
even/odd function
is there a ISEVEN or ISODD function in SQL? specifically mysql?
thanks
thanks
ASKER
sounds promising.
how would that look in a sql stmt such as:
select * from table1 where ISEVEN(field1)
thanks
how would that look in a sql stmt such as:
select * from table1 where ISEVEN(field1)
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note also that if you are using MySQL 5.0, you can declare your own ISEVEN function:
mysql> create function ISEVEN (i INT) RETURNS INT RETURN NOT(i&1);
Query OK, 0 rows affected (0.13 sec)
mysql> select ISEVEN(3);
+-----------+
| ISEVEN(3) |
+-----------+
| 0 |
+-----------+
1 row in set (0.06 sec)
mysql> select ISEVEN(4);
+-----------+
| ISEVEN(4) |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)
mysql> create function ISEVEN (i INT) RETURNS INT RETURN NOT(i&1);
Query OK, 0 rows affected (0.13 sec)
mysql> select ISEVEN(3);
+-----------+
| ISEVEN(3) |
+-----------+
| 0 |
+-----------+
1 row in set (0.06 sec)
mysql> select ISEVEN(4);
+-----------+
| ISEVEN(4) |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)
ASKER
excellent. thanks
-r-