Can I Create View With Parameter In MySQL?


Answer :

Actually if you create func:

create function p1() returns INTEGER DETERMINISTIC NO SQL return @p1; 

and view:

create view h_parm as select * from sw_hardware_big where unit_id = p1() ; 

Then you can call a view with a parameter:

select s.* from (select @p1:=12 p) parm , h_parm s; 

I hope it helps.


CREATE VIEW MyView AS    SELECT Column, Value FROM Table;   SELECT Column FROM MyView WHERE Value = 1; 

Is the proper solution in MySQL, some other SQLs let you define Views more exactly.

Note: Unless the View is very complicated, MySQL will optimize this just fine.


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?