MySql VIEW remove subquery in FROM condition -


im newbie sql , im trying create views buts mysql yell error

error 1349 (hy000): view's select contains subquery in clause

how can remove subquery in condition , same results in view?

select actual,          curr,          case when actual > anterior 'raise'              when actual < anterior 'drop' else 'nothing'          end 'status'  (          select o.i_price actual, o.i_currency curr,              (                 select i.i_price                  info                  i.i_article_id = 1                    , i.i_insert < o.i_insert                  order i.i_insert desc limit 1             ) anterior          info o          o.i_article_id = 1          order o.i_insert          desc limit 1 ) q 

you cannot use dinamica subquery during creation of view should create proper view subquery

    create view my_q      select o.i_price actual, o.i_currency curr,                  (                     select i.i_price                      info                      i.i_article_id = 1                        , i.i_insert < o.i_insert                      order i.i_insert desc limit 1                 ) anterior              info o              o.i_article_id = 1              order o.i_insert              desc limit 1 

and call view in top view

    create  view my_top_view       select actual,              curr,              case when actual > anterior 'raise'                  when actual < anterior 'drop' else 'nothing'              end 'status'       my_q; 

with performance suffer .. overcome error must not use subquery dynamics .. if can better rewrite query .


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -