How SQL selects between two strings/texts?

Solution 1:

Your question is rather baffling. This code works:

WHERE Price BETWEEN 100 AND 300

It is turned into:

WHERE Price >= 100 AND Price <= 300

Similarly, your first condition is equivalent to:

WHERE ProductName >= 'Geitost' AND
      ProductName <= 'Pavlova'

So the question is about how strings are compared. The short answer is "how they appear in the dictionary". Of course, there are lots of dictionaries in the world. The more complete answer is based on collations, which describe the alphabetic ordering of strings.

Here is the MySQL documentation for collations and character sets. Although some details such as the names of the collations and the syntax for functions may vary, the idea is similar across databases.