开发者社区 问答 正文

从表A中读取数据,将这些数据作为视图的列:报错

有表A,根据一定的条件查询出符合条件的数据,此时,需要将这些数据(查询出来的数据如:stu_id、stu_class)作为视图的字段,创建一个视图(create view select stu_id,stu_class from 表B),请问如何写语句?

展开
收起
kun坤 2020-06-07 22:31:20 426 分享 版权
1 条回答
写回答
取消 提交回答
  • create view view_name as  select stu_id,stu_class from 表B######回复 @沸羊羊 : 可以写个触发器,里面动态create or replace视图,你试下是否可以解决问题~~######回复 @pleatu : 您好,表B的字段名是固定的,但是我查询几个字段,却是从表A中的fields_to_fields控制的,查询表A,满足一定的条件,查出来的数据不一样,也即是去查询表A时,查询的字段不一样######回复 @沸羊羊 : 怎么个变化情况?规律有么??######回复 @沸羊羊 : 表B的字段名会变化?######我现在就是不知道如何将 stu_id,stu_class 传递给 select xxx from 表B,请问如何传递?######create view  view_name  as  select stu_id,stu_class from (select …… from A where ……)B######您好,stu_id,stu_class 不是固定的,是动态的,怎么把查出来的stu_id ,stu_class 作为字段,去创建视图?

    2020-06-07 22:31:24
    赞同 展开评论
问答地址: