我有一个包含多个值的视图。该视图被直接调用到我的ERP中的下拉列表中。我想知道是否可以根据ERP中的另一个字段来限制此视图的值?
使用字段打开表单的页面将调用3个过程:before_open,before_close,after_save
我找不到任何信息。
我已经尝试过使用where子句来限制值,但是它没有用。
//我的观点
CREATE VIEW Values
AS
SELECT N_values = 1 , Value = 'Working'
UNION ALL
SELECT N_values = 2 , Value = 'Pause'
UNION ALL
SELECT N_values = 3 , Value = 'Home'
UNION ALL
SELECT N_values = 4 , Value = 'Vacations'
GO
///要限制值,我这样做是在ID像1,5,6
IF(field = 'Not at work') SELECT field FROM view WHERE N_values IN(3,4)
我希望下拉列表的输出仅为[N_values] 3和4,但是我得到了所有列表。
答案 0 :(得分:0)
您是否正在寻找where
子句?
SELECT field
FROM view
WHERE (@field = 'Not at work' and N_values IN (3, 4)) OR
(@field <> 'Not at work');
答案 1 :(得分:0)
为什么不添加其他(计算列)working
CREATE VIEW Values
AS
SELECT N_values = 1 , Value = 'Working'
UNION ALL
SELECT N_values = 2 , Value = 'Pause'
UNION ALL
SELECT N_values = 3 , Value = 'Home'
UNION ALL
SELECT N_values = 4 , Value = 'Vacations'
GO
//this view add a 'calculated field' that is true if forking
CREATE VIEW values_extended AS
SELECT *, case when n_values >2 then 'not-working' else 'working' end
FROM values
GO
所以你可以选择
select n_values, Value
from value_extended
where working like 'not-working'
会给你
3, Home
4, Vacations