Why is it not recommended to use the mixture of quoted as well as unquoted values in MySQL IN() function’s list?


Actually, MySQL has different comparison rules for quoted values such as strings and unquoted values such as numbers. On mixing the quoted and unquoted values in IN() function list may lead to the inconsistent result set. For example, we must not write the query with IN() function like below −

Select Salary from employee where ID IN(1,’a’,2,3,’c’)

Instead of this the better way to write the above query is as follows −

Select Salary from employee where ID IN(‘1’,’a’,’2’,’3’,’c’)

Updated on: 30-Jul-2019

40 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements