How to create a user view using a table in database management system?
如何使用数据库管理系统中的表创建用户视图?
How can we write it in SQL code?
我们如何用SQL代码编写它?
I tried to do this...CREATE VIEW VIEW3 AS SELECT MGRSSN, FNAME, LNAME, BDATE, SALARY FROM DEPARTMENT, EMPLOYEE WHERE DEPARTMENT.MGRSSN = EMPLOYEE.SSN ;
我试图这样做...创建视图VIEW3作为选择MGRSSN,FNAME,LNAME,BDATE,SALARY从部门,员工在哪里DEPARTMENT.MGRSSN = EMPLOYEE.SSN;
1 个解决方案
#1
0
Without knowing your exact table structure I cannot help you perform the query 100% but this should get you in the right direction and solve your issue:
在不知道您的确切表结构的情况下,我无法帮助您100%执行查询,但这应该可以帮助您找到正确的方向并解决您的问题:
The CREATE VIEW Syntax:
CREATE VIEW语法:
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
You're performing a JOIN incorrectly:
您正在执行错误的加入:
CREATE VIEW VIEW3 AS SELECT MGRSSN, FNAME, LNAME, BDATE,
SALARY FROM DEPARTMENT, EMPLOYEE WHERE DEPARTMENT.MGRSSN = EMPLOYEE.SSN;
Should look like:
应该是这样的:
CREATE VIEW VIEW3
AS SELECT MGRSSN, FNAME, LNAME, BDATE, SALARY
FROM DEPARTMENT a, EMPLOYEE b
WHERE a.MGRSSN = b.SSN
You just have to query it:
你只需要查询它:
SELECT * FROM [VIEW3]
For further reading I suggest you look in the SQL documentation for CREATE VIEW statements and learn how to work with the virtual table.
为了进一步阅读,我建议您查看SQL文档中的CREATE VIEW语句,并了解如何使用虚拟表。
#1
0
Without knowing your exact table structure I cannot help you perform the query 100% but this should get you in the right direction and solve your issue:
在不知道您的确切表结构的情况下,我无法帮助您100%执行查询,但这应该可以帮助您找到正确的方向并解决您的问题:
The CREATE VIEW Syntax:
CREATE VIEW语法:
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
You're performing a JOIN incorrectly:
您正在执行错误的加入:
CREATE VIEW VIEW3 AS SELECT MGRSSN, FNAME, LNAME, BDATE,
SALARY FROM DEPARTMENT, EMPLOYEE WHERE DEPARTMENT.MGRSSN = EMPLOYEE.SSN;
Should look like:
应该是这样的:
CREATE VIEW VIEW3
AS SELECT MGRSSN, FNAME, LNAME, BDATE, SALARY
FROM DEPARTMENT a, EMPLOYEE b
WHERE a.MGRSSN = b.SSN
You just have to query it:
你只需要查询它:
SELECT * FROM [VIEW3]
For further reading I suggest you look in the SQL documentation for CREATE VIEW statements and learn how to work with the virtual table.
为了进一步阅读,我建议您查看SQL文档中的CREATE VIEW语句,并了解如何使用虚拟表。