开发者

Standard SQL - CHAR to ASCII

开发者 https://www.devze.com 2023-01-16 17:09 出处:网络
Using standard SQL, SQL-92, how can I convert a character to an开发者_运维知识库 ASCII value?

Using standard SQL, SQL-92, how can I convert a character to an开发者_运维知识库 ASCII value?

In MySQL it's easy using the ascii() function, but SQL-92 doesn't have this.


It appears the SQL-92 standard doesn't even mention ASCII at all.

As you say, each RDBMS vendor would have its own implementation how to convert char->ascii and ascii->char.

Most name this function ASCII().

  • SQL Server ASCII
  • Postgresql ASCII
  • Oracle ASCII
  • MySQL ASCII


Create a lookup table with all the ASCII characters and their corresponding values -- there are only 127 of them -- and then just do SELECT [value] FROM [table] WHERE [character] = 'A' etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消