在phpmyadmin中使用计算创建视图

时间:2014-03-31 10:03:28

标签: mysql phpmyadmin sql-view

我试图通过phpmyadmin创建一个视图。它包含一些计算。 像

Select A,B,C,D,E, (IF(E>0,B,C)+A+D)

我怎么能这样做?

1 个答案:

答案 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]