SQL WHERE
Es ist das IF-Anweisung bei SQL.
Kunden
| kunden_id | vorname | nachname | |
|---|---|---|---|
| 1 | Alice | Meier | [email protected] |
| 2 | Bob | Schmidt | [email protected] |
Produkte
| produkt_id | produkt_name | preis |
|---|---|---|
| 1 | Laptop | 899.99 |
| 2 | Smartphone | 499.99 |
| 3 | Tablet | 299.99 |
Bestellungen
| bestellung_id | kunden_id | bestell_datum |
|---|---|---|
| 1 | 1 | 2024-10-10 |
| 2 | 2 | 2024-10-11 |
Bestellpositionen
| bestellposition_id | bestellung_id | produkt_id | menge |
|---|---|---|---|
| 1 | 1 | 1 | 1 |
| 2 | 2 | 2 | 2 |
| 3 | 2 | 3 | 1 |
SELECT *
FROM Bestellpositionen
WHERE produkt_id = 2;
Ergebnis
| bestellposition_id | bestellung_id | produkt_id | menge |
|---|---|---|---|
| 2 | 2 | 2 | 2 |