© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
M. SimonGetting Started with SQL and Databaseshttps://doi.org/10.1007/978-1-4842-9493-2_6

6. Joining Tables

Mark Simon1  
(1)
Ivanhoe VIC, VIC, Australia
 
If you select the data from the paintings table:
SELECT *
FROM paintings;
You will see the artist is represented by the artistid, not the name or any other detail. That is how it should be in good database design, but it’s not convenient. In the previous chapter, you got around this by including a subquery:
SELECT
    title,
    (SELECT givenname||' '||familyname FROM artists
        WHERE artists.id=paintings.artistid) AS artist
    --  etc
FROM paintings;

Apart from being tedious, subqueries can also be costly in ...

Get Getting Started with SQL and Databases: Managing and Manipulating Data with SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.