使sql视图可编辑 [英] Make sql view editable

查看:140
本文介绍了使sql视图可编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使此sql视图合并了一些表并且可以工作,但是它不能在其中直接直接编辑(我不能插入,删除,编辑)数据,但前提是我这样做了所以在初始表中,有什么方法可以直接在视图中直接进行同样的操作(编辑数据)?

I've made this sql view to combine some tables and it works, but it's not editable (i can't insert, delete, edit) data directly in it, but only if i do so in the initial tables, so is there any way to do the same (edit data) directly into the view?

Create view table4 as
Select table1.firstname, table1.lastname, table2.bodyweight, table3.bodyfat
From table1
LEFT JOIN table2 ON table1.table1_id = table2.table2_id;
LEFT JOIN table3 ON table1.table1_id = table3.table3_id;

推荐答案

在MySQL中,您无法更新具有"LEFT JOIN"的视图,但是,如果可以将其转换为"JOIN",则应该可以.

In MySQL you cannot update a view that has "LEFT JOIN", however if you can convert those to "JOIN" you should be OK.

Create view table4 as
Select table1.firstname, table1.lastname, table2.bodyweight, table3.bodyfat
From table1
JOIN table2 ON table1.table1_id = table2.table2_id;
JOIN table3 ON table1.table1_id = table3.table3_id;

请参见此处以获取有关内容的参考允许在可更新的视图中使用.

See here for reference to what is allowed in updatable views.

这篇关于使sql视图可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆