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

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable