简体   繁体   English

如何显示从一张表到另一张表的列

[英]How do I display a column from 1 table to another table

There are 2 tables, a table named species and another table named planet . 有2个表格,一个名为species的表,另一个名为planet表。

I want to display the name, average_height, hair_color, skin_color, homeworld and population . 我想显示name, average_height, hair_color, skin_color, homeworldpopulation All of the above is in the species table except for population which is in planet table. 以上所有内容都在species表中,但planet表中的population除外。

What is the query do I have to do to display all of these columns 要显示所有这些列,我需要做什么查询

I am using SQL Developer 我正在使用SQL Developer

Species Table 种类表

ID
homeworld
name
average_height
skin_color
hair_color
eye_color
language
average_lifespan
classification

Planet Table 行星表

ID
diameter
climate
surface_water
name
rotation_period
terrain
gravity
orbital_period
population

The basic query would be 基本查询将是

SELECT s.NAME,
       s.AVERAGE_HEIGHT,
       s.HAIR_COLOR,
       s.SKIN_COLOR,
       s.HOMEWORLD,
       p.POPULATION
  FROM PLANET p
  INNER JOIN SPECIES s
    ON s.HOMEWORLD = p.ID

if SPECIES.HOMEWORLD is in fact a foreign key to PLANET.ID 如果SPECIES.HOMEWORLD实际上是PLANET.ID的外键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何显示其他表格中的该列? - How do I display this column from another table? 如何替换另一个表格列中的表格字符串 - How do I replace strings of a table from another table column 如何从另一个表列中选择一个表? - How do I select a table from another table column? 如何显示另一个表中的列的值 - how to display value of column from another table 如何使用同一表中另一列的数据更新表中的列? - How do I update a column from a table with data from a another column from this same table? 如何更新从另一个表的默认空值列中选择值的表的列? - How do I update a column of a table which picks values from a default null valued column of another table? 如何按表A中的列对表B中的另一列进行分组? SQL - How do I group by column from table A to another column in table B? SQL 如何在 MySQL 中显示一个表中的所有行并从另一个表中计数 - How do I display all rows from a table and count from another table in MySQL 如何从一个表中选择与表中的列值相匹配的数据? - How do I select data from one table where column values from that table match the conatenated column values of another table? 如何计算一个表中的值,然后在另一表中显示相同的值? - How do I count the value from one table and then display the same value in another table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM