BaşlayınÜcretsiz Başlayın

Joining on relations

You've used the following diagram in the previous exercise:

Database Schema for Customer and Order

You've learned that you can use the read_sql() function from pandas to query the database. The real power of SQL is the ability to join information from multiple tables quickly. You do this by using the JOIN statement.

When joining two or more tables, pandas puts all the columns of the query result into a DataFrame.

Bu egzersiz

Introduction to Data Engineering

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Complete the SELECT statement, so it joins the "Customer" with the "Order" table.
  • Print the id column of data. What do you see?

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Complete the SELECT statement
data = pd.read_sql("""
SELECT * FROM "Customer"
INNER JOIN "____"
ON "Order"."____"="Customer"."____"
""", db_engine)

# Show the id column of data
print(data.____)
Kodu Düzenle ve Çalıştır