代码之家  ›  专栏  ›  技术社区  ›  Ankur Singhal

Oracle | Varchar2 |数字相等|不同输出

  •  0
  • Ankur Singhal  · 技术社区  · 3 年前

    我有一张甲骨文的桌子 表1 .

    现在当我查询时,不同的查询有不同的输出,尽管记录存在。

    select * from Table1 where ticketNo = '0900000106'; -- Fetches the record
    select * from Table1 where ticketNo = '0810087720'; -- Fetches the record
    select * from Table1 where ticketNo = '0050001104'; -- Fetches the record
    select * from Table1 where ticketNo = '3180000013'; -- Fetches the record
    

    从表1中选择*,其中ticketNo='900000100';--没有 获取记录

    select * from Table1 where ticketNo = '5889770';    -- Fetches the record
    
    select * from Table1 where ticketNo = 0900000106; -- Fetches the record
    select * from Table1 where ticketNo = 0810087720; -- Fetches the record
    select * from Table1 where ticketNo = 0050001104; -- Fetches the record
    select * from Table1 where ticketNo = 3180000013; -- Fetches the record
    

    从表1中选择*,其中ticketNo=900000100;--获取 记录

    select * from Table1 where ticketNo = 5889770;    -- Fetches the record
    

    我不明白为什么为数不多的记录比较失败。

    我使用sqldeveloper来查询上面的内容。

    Oracle IDE 17.4.1.054.0712

    1 回复  |  直到 3 年前
        1
  •  0
  •   Serg    3 年前

    When comparing a character value with a numeric value, Oracle converts the character data to a numeric value

    例如,当你比较 ticketNo = 900000106 ticketNo的字符值“0900000106”被转换为数字900000106,并匹配正确的相等项。