MNM
MNM

Reputation: 37

MYSQL if (string in ( 0) ) returns TRUE

The following mysql query result returns 'TRUE',

select if('testString' in ( 0 ), 'TRUE', 'FALSE') from sampleTable 

Can someone explain why please ?

Upvotes: 1

Views: 157

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

You can try using

 select  cast('testString' AS UNSIGNED)  from dual ;  // return 0 

do the fact because the cast for 'testString' AS UNSIGNED is = 0

then

select if( 'testString' in ( 0 ), 'TRUE', 'FALSE') from DUAL ;

match for casted value the 0 in (0) and return TRUE

Upvotes: 1

Related Questions