设置列以自动从引用的表中提取数据
I have one column called 'speeding' in a table containing many other columns. This column contains an integer that is foreign key to an entry on a table named Speeding. This table has columns 1-25 and an id that is referenced by the 'speeding' column from the first table.
我在一个包含许多其他列的表中有一个名为“speeding”的列。此列包含一个整数,该整数是名为Speeding的表上的条目的外键。此表包含第1-25列以及第一个表中“超速”列引用的ID。
Besides using join, is there any setting I can set on 'speeding' to make it automatically pull the associated data from the table Speeding?
除了使用join之外,是否有任何设置我可以设置'speeding'以使其自动从表Speeding中提取相关数据?
1 个解决方案
#1
0
You could create a view, a view is basically a SQL statement that is stored on the MySQL server and acts like a table
您可以创建一个视图,一个视图基本上是一个存储在MySQL服务器上的SQL语句,就像一个表
CREATE VIEW ViewName AS
SELECT tbl1.data, tbl2.speeding
FROM tbl1
INNER JOIN tbl2 ON tbl2.key = tbl1.key;
http://dev.mysql.com/doc/refman/5.0/en/create-view.html
You then use the view as you would use any table
然后,您可以像使用任何表一样使用视图
SELECT data, speeding
FROM ViewName
更多相关文章
- MySQL数据库8(二十)视图
- 如何知道php脚本中的名称是指mysql表还是mysql视图
- MySQL视图-(视图创建,修改,删除,查看,更新数据)
- 在平台上获取,可移植,更大和更快(无符号)的整数类型
- ng- repeat显示的行等于no属性,甚至不显示html视图上的数据
- 桌面视图中的SlikNav多级菜单?
- 在单选按钮上选中/取消选中,加载/隐藏部分视图
- 如何在当前视图中始终保持水平底部滚动条
- 切换元素类并使用旧类在视图中添加新元素