输入框参数化

定义一个变量,要求输入一个值比如001,sql查询比如

 where userid=001

的数据

输入2个值,比如001,002 sql查询

where userid in(001,002)

的数据

metabase上想实现这个效果,请教了一下大佬,学到了新写法。

select * from account.users  where instr(concat(',',{{userid}},','),concat(',',id,','))>0 

其中{{userid}}为变量的意思这样就实现了选项框输多个值,逗号分开,查询匹配到的相应数据。

原文地址:https://www.cnblogs.com/5sdba-notes/p/14076498.html