質問

私は<のhref =「https://stackoverflow.com/questions/1895500/mysql-views-referencing-one-calculated-field-by-name-in-another-calculated-fie」と同じ疑問を持っていますタイトル= "#1895500">#1895500 のが、PostgreSQLのないMySQLでます。

どのように私は、例えば、計算されたフィールドを持つビューを定義することができます:

 (mytable.col1 * 2) AS times_two

...と、最初の1に基づいている別の計算フィールドを作成します:

 (times_two * 2) AS times_four

...

役に立ちましたか?

解決

formlaがどのように重いによっては、サブクエリを使用することができます:

select inner.*, times_two * 2 from
(select mycol * 2 as times_two from table) sub

または演算を書き換えます:

select mycol * 2, mycol * 2 * 2 from table

他のヒント

  

使用このステートメント

 
CREATE  VIEW  view_name as  SELECT  column_name*2 as new_col1 , column_name*4 as new_col2  from table_name ; 

select * from view_name ; 

If you want use this view column values. use following things 

create view new_viwe as select new_col1*2 as final_column from view_name ; 

select * from new_view ; 


ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top