BETWEEN OPERATOR for VARCHAR data type

When I am using this query:

SELECT * FROM `product` WHERE phdd BETWEEN '1GB' AND '500GB'

It returns the rows that has values 1TB also.Why that?

Because the binary value for the string "“1TB” is between that for “1GB” and “500GB”

If you want to deal with them as numeric data types best not to use string data type.

Maybe try numeric byte values instead?

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.