문제

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

도움이 되었습니까?

해결책 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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top