Why is MySQL select returning different result for the same value depending if it is quoted -
while querying table of products this:
select product_id products product_id = 1701114; i 2 rows result: 1701114 , 1701114b.
but after adding single quotation marks this:
select product_id products product_id = '1701114'; i expected single row result.
product_id column primary key of varchar type , unquoted value digital may cause, it's quite surprising equality sign changes 'like'
your column product_id varchar column. bad idea compare integer (1701114) rather string ('1701114').
what happens mysql silently converts product_id values numbers in order compare them 1701114. '1701114b' no number , should not convertable number, raise error, in opinion. however, mysql developers have decided convert nonetheless starting left right , going far possible. convert '1701114b' 1701114, hence unexpected match.
Comments
Post a Comment