Kapitel 10-1

Schreiben Sie eine Abfrage, die jeden Produktnamen zusammen mit den zugehörigen Konten zurückgibt (nutzen Sie dabei die product_cd-Spalte der account-Tabelle, um eine Verbindung zur product-Tabelle zu schaffen). Beziehen Sie alle Produkte ein, auch die, zu denen noch keine Konten eröffnet wurden.

mysql> SELECT p.product_cd, a.account_id, a.cust_id, a.avail_balance
    -> FROM product p LEFT OUTER JOIN account a
    ->   ON p.product_cd = a.product_cd;
+------------+------------+---------+---------------+ | product_cd | account_id | cust_id | avail_balance | +------------+------------+---------+---------------+ | AUT | NULL | NULL | NULL | | BUS | 21 | 10 | 0.00 | | BUS | 22 | 11 | 9345.55 | | CD | 3 | 1 | 3000.00 | | CD | 13 | 6 | 10000.00 ...

Get Einführung in 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.