When i write this query
SELECT cd.title, cd.city FROM coupon_detail cd WHERE cd.id = 260;
return
title city
--------------- ------
Butterfly world Mohali
and when i write
SELECT cd.title, cd.city FROM coupon_detail cd WHERE cd.id = '260abcxyz';
return
title city
--------------- ------
Butterfly world Mohali
see the second one is wrong. i want to get the value only IF ID EXACTLY MATCH … how to solve this. thanks for your help.
You could convert the
idto a string so the comparison will be done exactly. You could useLIKEto cause an implicit conversionor alternative, you can perform the cast explicitly
However, if all your IDs are integers, it’s probably more appropriate to check these values before you try to query the database. (If the ID you’re querying with isn’t a number, there can’t be a match anyway.)