V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
TomVista
V2EX  ›  问与答

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

  •  
  •   TomVista · 289 天前 · 172 次点击
    这是一个创建于 289 天前的主题,其中的信息可能已经有所发展或是发生改变。

    代码中常见的魔法数字处理方式是定义常量 枚举,那么 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
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3145 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 14:01 · PVG 22:01 · LAX 07:01 · JFK 10:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.