V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
TomVista
V2EX  ›  问与答

sql 中的字典值魔法数字怎么处理?

  •  
  •   TomVista · Jul 27, 2023 · 481 views
    This topic created in 1015 days ago, the information mentioned may be changed or developed.

    代码中常见的魔法数字处理方式是定义常量 枚举,那么 sql 中呢?

    select * from table where type = '1'
    
    const web = 1
    const app =2
    
    select * from table where type = '+web+'
    
    select * from table where locate('+web+',type)>0 or locate('+app+',type)>0
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3066 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 15:09 · PVG 23:09 · LAX 08:09 · JFK 11:09
    ♥ Do have faith in what you're doing.