Reputation: 2811
I have a table products
with the next id
column
I am using IN
function instead of WHERE
because I expected multiples products ids
In this case only come one product id.
SELECT id FROM `products` WHERE id IN (00010001)
The above sql query returns
But that is not I expected, I expected only the first row 00010001
.
I need the value exact, How to accomplish that with IN
function ?
Upvotes: 1
Views: 43
Reputation: 1270773
Your id
is a string, so you want string comparisons:
SELECT proidxxx
FROM `products`
WHERE id IN ('00010001')
You are mixing types, so MySQL is silently converting the id
to a number. It is matching any id
where the initial digits -- when converted to a number -- are equal to 10001
.
Upvotes: 3