我试图通过phpmyadmin创建一个视图。它包含一些计算。 像
Select A,B,C,D,E, (IF(E>0,B,C)+A+D)
我怎么能这样做?
答案 0 :(得分:1)
试试这个:
create view view_name -- provide an appropriate name for view
as
select A,B,C,D,E, (IF(E>0,B,C)+A+D) as total
-- include from table if required
-- from my_table
请参阅:
MySQL: CREATE VIEW Syntax
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW view_name [(column_list)] AS select_statement [WITH [CASCADED | LOCAL] CHECK OPTION]