嗨,我目前正在为大学考试而做,我对当前的任务还很了解
我知道我应该独自解决这个问题,但我陷入困境并感到绝望
谁和施米茨女士借了同一本书?打印出他们的姓氏
尽管您不允许使用子查询
这是我的尝试:
SELECT l.Nachname
FROM Ausleihe as a
LEFT JOIN Leser as l on a.LeserOID = l.LeserOID
WHERE ExID IN (
SELECT ExID
FROM Ausleihe
LEFT JOIN Leser L2 on Ausleihe.LeserOID = L2.LeserOID
WHERE l2.Nachname = 'Schmitz'
);
这很完美,但是它带有子查询。
**Buch -> Book**
BuchOID -> BookOID
Titel -> Title
Verfasser -> Author
**Vormerkung -> Reservartion**
LeserOID -> ReaderOID
BuchOID -> BookOID
VormDat -> Reservation date
**Leser -> Reader**
LeserOID -> ReaderOID
Nachname -> Last name
Mail
**Exemplar -> Copy**
BuchOID -> BookOID
ExID -> CopyID
AnschDat -> Date of aqusition
**Ausleihe -> Lending**
BuchOID -> BookOID
ExID -> CopyID
LeserOID -> ReaderOID
LNr -> *PK of this table*
ADat -> Lending date
RDat -> Return date
**Mahnung -> Reminder**
MahnungOID -> ReminderOID
LeserOID - > ReaderOID
BuchOID -> BookOID
ExID -> CopyID
Datum -> date
Betrag -> amount
答案 0 :(得分:1)
您可以在下面尝试-
{'ask_size': 1.0105962, 'ask_price': 3422.58, 'time_exchange': '2019-02-05T13:11:10.0724918Z', 'symbol_id': 'BITSTAMP_SPOT_BTC_USD', 'bid_size': 2.49846056, 'last_trade': {'uuid': 'a2894632-441e-4ad5-bfb8-c61bd84a724e', 'time_exchange': '2019-02-05T13:10:51.0000000Z', 'size': 0.00553675, 'taker_side': 'BUY', 'price': 3422.58, 'time_coinapi': '2019-02-05T13:10:51.2541019Z'}, 'bid_price': 3421.8, 'time_coinapi': '2019-02-05T13:11:10.0724918Z'}
答案 1 :(得分:1)
如果使用左连接,如果没有关系,它将返回带有null的结果,因此如果不为null,则需要添加条件
SELECT l.Nachname
FROM Ausleihe as a
LEFT JOIN Leser as l on a.LeserOID = l.LeserOID
LEFT JOIN Leser L2 on Ausleihe.LeserOID = L2.LeserOID
WHERE L2.Nachname is not null and L2.Nachname = 'Schmitz'
或者使用内部联接,您可以执行以下操作
SELECT l.Nachname
FROM Ausleihe as a
LEFT JOIN Leser as l on a.LeserOID = l.LeserOID
INNER JOIN Leser L2 on (Ausleihe.LeserOID = L2.LeserOID AND and L2.Nachname = 'Schmitz')
或类似
SELECT l.Nachname
FROM Ausleihe as a
LEFT JOIN Leser as l on a.LeserOID = l.LeserOID
INNER JOIN Leser L2 on Ausleihe.LeserOID = L2.LeserOID
WHERE L2.Nachname = 'Schmitz'