Domanda

In an sql where condition there is a value like below

select * from tabl
where
code not between 'A00' and 'B99'

how does this work? till now i was thinking it works only with numeric and date

È stato utile?

Soluzione 2

The BETWEEN operator will treat these as varchars, and apply its comparison rules accordingly:

BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression.

SQL uses a list of the ASCII codes to determine which to sort where and in what order.

Altri suggerimenti

The same way as ORDER BY works on varchar values.

Every char has its ASCII code and sort order, so every value can be compared by its ASCII code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top