Kapitel 9-1

Schreiben Sie für die account-Tabelle eine Abfrage, die eine Filterbedingung mit einer nicht-korrelierten Unterabfrage der product-Tabelle verwendet, um alle Darlehenskonten zu finden (product.product_type_cd = 'LOAN'). Rufen Sie die Kontonummer (Account ID), den Produktcode, die Kundennummer (Customer ID) und den verfügbaren Saldo (available balance) ab.

mysql> SELECT account_id, product_cd, cust_id, avail_balance
    -> FROM account
    -> WHERE product_cd IN (SELECT product_cd
    ->   FROM product
    ->   WHERE product_type_cd = 'LOAN'); +------------+------------+---------+---------------+ | account_id | product_cd | cust_id | avail_balance | +------------+------------+---------+---------------+ | 21 | BUS | 10 | 0.00 | | 22 | BUS | 11 | ...

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.