我的 SQL 查询在应该吐出 20 个时吐出 3000 个查询,我使用的是 Oracle。
以下是表格:
Item (itemNumber, itemName, itemDescription, itemValue, itemLocation,
categoryID, sellerUsername)
Auction (auctionNumber, currency, startDateTime, endDateTime, shippingTerms,
startBidAmount, reserveAmount, bidIncrementAmount, noOfItems, itemSold,
itemNumber feedbackDateAndTime, rating, comments, paymentDate, paymentid)
Bid (bidderUsername, auctionNumber, bidDateTime,bidAmount)
和我的查询
SELECT
i.itemname,
i.itemdescription,
i.itemvalue,
CASE
WHEN i.itemnumber=a.itemnumber and a.itemSold='y' THEN 'Sold'
WHEN a.auctionnumber != b.auctionnumber and TO_CHAR(sysdate,'DD-MON-YY')>endDateTime THEN 'No Bids on that closed auction'
WHEN TO_CHAR(sysdate,'DD-MON-YY')<a.endDatetime and a.auctionnumber=b.auctionnumber
and reserveamount>(
SELECT b.bidAmount
FROM dbf12.bid b, dbf12.auction a
WHERE a.auctionnumber=b.auctionnumber
GROUP BY b.bidAmount
HAVING b.bidAmount= max(b.bidAmount)) THEN 'No Bids that meets the reserve'
ELSE 'Auction Still Open'
END
FROM
dbf12.item i, dbf12.auction a, dbf12.bid b;