Relation:Tutorial 8
Join
Often, you are not working with one table but with multiple tables. You can combine values based on common values.
We reuse the table films.csv but also have a second table with informations on directors directors.csv.
director | country | gender |
---|---|---|
Godard | France | M |
Truffaut | France | M |
Varda | France | F |
Kluge | Germany | M |
von Trotta | Germany | F |
Both tables share the column director. We can combine them with a natural join
film | director | year | country | gender |
---|---|---|---|---|
A bout de souffle | Godard | 1960 | France | M |
Tirez sur le pianiste | Truffaut | 1960 | France | M |
Cléo de 5 à 7 | Varda | 1962 | France | F |
Jules et Jim | Truffaut | 1962 | France | M |
Pierrot le fou | Godard | 1965 | France | M |
Week-End | Godard | 1967 | France | M |
Die verlorene Ehre der Katharina Blum | von Trotta | 1975 | Germany | F |
Der starke Ferdinand | Kluge | 1976 | Germany | M |
Sans toi ni loi | Varda | 1985 | France | F |
Columns are not always exactly matchable if they are not from a database, so you may have to use
Now we can ask more complex questions
Show the titles of female directors after 1970
film |
---|
Die verlorene Ehre der Katharina Blum |
Sans toi ni loi |
Go to Tutorial 9
' ===Join===
' Often, you are not working with one table but with multiple tables. You can combine values based on common values.
' We reuse the table [[Media:films.csv]] but also have a second table with informations on directors [[Media:directors.csv]].
read "directors.csv"
' Both tables share the column director. We can combine them with a natural join
read "films.csv"
read "directors.csv"
join natural
' Columns are not always exactly matchable if they are not from a database, so you may have to use
' Now we can ask more complex questions
' '''''Show the titles of female directors after 1970'''''
read "films.csv"
read "directors.csv"
join natural
select gender == "F" and year > 1970
project film
' Go to [[Tutorial 9]]