When executing
SELECT item_id FROM (`phppos_items`) WHERE `item_id` = '1001-1001'
I get back this row
1001
item_id is an int auto-incrementing column. How do I prevent this from happening?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
item_idis an integer column.Therefore, when you compare it to a string (
'1001-1001'), this string is converted to an integer. The string'1001-1001'is converted to the integer1001, so it matches the column you got back.As for how to avoid it, it depends on what you’re trying to do. If you’re trying to find a row having the id
'1001-1001', that just won’t exist, as the column contains only integers.If you’re trying to find all ids inside of a range, try using the
BETWEEN ... AND ...operator instead: