【发布时间】:2019-07-16 07:33:06
【问题描述】:
这是我的桌子
我的查询是当我使用 cubbersId 搜索时,如果我得到空数据 where cubbersId = 0 否则 where cubbersId = 1 (my_search_data) 它类似于存储过程。
我试过这个查询
SELECT * FROM hometestimonial WHERE (CASE
WHEN cubbersId IS NOT NULL THEN cubbersId = 1
ELSE cubbersId = 0
END)
我搜索cubbersId = 1,所以我得到了3 datas。但是我尝试在 cubbersId 2 中搜索 cubbersId = 2 表示 no data,所以在这种情况下我需要显示 cubbersId = 0 数据。
这是我的结果:
where cubbersId = 1数据:
【问题讨论】:
标签: jquery mysql sql select case