TomVista
V2EX  ›  问与答

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

By TomVista at 2023 年 7 月 27 日 · 792 次点击

代码中常见的魔法数字处理方式是定义常量 枚举,那么 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
目前尚无回复
© 2026 V2EX · 21ms · 3.9.8.5