创建后视图以组合多个表数据
我有多个具有不同列名称的表,如下,
客户表: c_id, customer_name, phone_number, postal_code
员工表:员工_name,e_id,mobile_no,zip_code
学生表:s_id,student_name,post_code
我需要创建视图来组合诸如下面的
用户表<>用户表<> /strong>:userId(c_id,e_id,s_id),用户名(所有名称列),zip_code,contact
示例数据
客户表:
| c_id | Company_Name | Phone |
|----------------------------------|
| 1 | Company 1 | *******|
|----------------------------------|
员工表:
| e_id | Employee_Name | Mobile |
|----------------------------------|
| 1 | employee 1 | *******|
|----------------------------------|
期望查看:
| userId | user_Name | contact |
|-------------------------------------|
| c_1 | Company 1 | ******* |
|-------------------------------------|
| e_1 | employee 1 | ******* |
|-------------------------------------|
如何创建视图,请帮助我,提前致谢
I have multiple tables with different column names like below,
customer table:
c_id,
customer_name,
phone_number,
postal_code
Employee Table: Employee_name, e_id, mobile_no,zip_code
student Table: s_id, student_name, post_code
I need to create view to combine those tables like below
User Table: userId (c_id, e_id, s_id), userName (all name columns), zip_code, contact
Sample Data
Customer Table:
| c_id | Company_Name | Phone |
|----------------------------------|
| 1 | Company 1 | *******|
|----------------------------------|
Employee Table:
| e_id | Employee_Name | Mobile |
|----------------------------------|
| 1 | employee 1 | *******|
|----------------------------------|
Expected View:
| userId | user_Name | contact |
|-------------------------------------|
| c_1 | Company 1 | ******* |
|-------------------------------------|
| e_1 | employee 1 | ******* |
|-------------------------------------|
how to create the view please help me, Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用
Union
或联合所有
根据重复值。基于数据a href =“ https://dbfiddle.uk/?rdbms = postgres_10&; fiddle = 88f7473090fc386cdc666666dfbd30c37111”
<
just use
Union
orUnion All
depending on duplicate values. based on datadbfiddle
based on tables