tags:

views:

29

answers:

3

i have column a ,column b in emp table. i like to retrieve values from that column find the difference between them. if i get 0 as difference i will return true else i will return false using functions.i am new to database so only i don't know how to do this.i like to know how to store the retrieved values from table to variable. i dont know how to return a value.

+2  A: 

MySQL doesn't really have booleans. TRUE and FALSE are aliases to 1 and 0, and the BOOL column type is just an alias for TINYINT(1). All expressions that appear to give boolean results actually return 0 or 1.

You could write your query as:

SELECT (a = b) AS a_equals_b
FROM emp
WHERE ...
Mark Byers
A: 

go to

http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.html

section

BOOL, BOOLEAN

Flakron Bytyqi
A: 
select a, b, if(a-b=0, true, false) as diff from emp;
Salil