[英]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, homeworld
和population
。 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.