Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to select columns after inner join

Once I have joined two dataframes by a specific column I then want to select specific columns from this table – how can I do this?

I have tried the following:

SELECT * 
FROM 
    land_birds
INNER JOIN
    sea_birds
ON
    land_birds.colour = sea_birds.colour

SELECT
    colour,
    beak,
    size, 
    weight
FROM
    TABLE

However I get the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

near "SELECT": syntax error

>Solution :

Instead of a second select, use the first one.

For example, this will get the name and flavor of each land and sea bird pair.

SELECT
  land_birds.nane, land_birds.flavor,
  sea_birds.name, sea_birds.flavor
FROM 
    land_birds
INNER JOIN
    sea_birds
ON
    land_birds.colour = sea_birds.colour

Note that because you’re joining two tables, you will get the columns of both tables in each row.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading