运行 SQL COUNT 代码 - 缺少括号
我正在尝试运行此 SQL 命令,但它给我一个错误,表明 SQL 命令未正确结束。请注意,我使用的是 Oracle 的 11g。
SELECT BookTitle.btName, BookTitle.Isbn FROM BookTitle AND SELECT COUNT(Isbn)
FROM BookTitle
JOIN Loan ON (Borrower.borId = Loan.borId)
JOIN BookCopy ON (Loan.bcId = BookCopy.bcId)
JOIN Authorship ON (BookCopy.isbn = Authorship.isbn)
JOIN Author ON (Author.authorID = Authorship.authorID)
WHERE Loan
ORDER BY Loan.dateOut DESC;
您能指导我找出问题所在吗?
有几个表:书名、书本、作者、借阅、作者、出版商和借阅者。我需要找到借阅最多的书并列出所有书名和 isbn。
BookTitle contains ISBN(PK), btName, datePublished, pubId*, ageLower, ageUpper, value.
Borrower contains borID(PK), borName, borAddress and borMaxbook
BOokCopy cvontains bcID(PK), ISBN*, dateAcquired, dateDestroyed
oan contains borID(PH)*, bcID(OK)*, dateOut(FK), dateDue and dateBack
Publisher contains PubId(PK), pubName and pubAddress
Publisher cotains PubID(8), pubName, pubAddress
Authoer contains authorID(PK) and authorName
Authorship contains authorId*, and ISBN*
I'm trying to run this SQL command but it's giving me an error that the SQL command is not properly ended. Note, I'm using Oracle's 11g.
SELECT BookTitle.btName, BookTitle.Isbn FROM BookTitle AND SELECT COUNT(Isbn)
FROM BookTitle
JOIN Loan ON (Borrower.borId = Loan.borId)
JOIN BookCopy ON (Loan.bcId = BookCopy.bcId)
JOIN Authorship ON (BookCopy.isbn = Authorship.isbn)
JOIN Author ON (Author.authorID = Authorship.authorID)
WHERE Loan
ORDER BY Loan.dateOut DESC;
Can you kindly guide me to what's wrong ?
have several tables Book Title, BookCopy, Authorship, Loan, Author, Publisher and Borrower. I need to find the most borrowed book and list all titles and isbn.
BookTitle contains ISBN(PK), btName, datePublished, pubId*, ageLower, ageUpper, value.
Borrower contains borID(PK), borName, borAddress and borMaxbook
BOokCopy cvontains bcID(PK), ISBN*, dateAcquired, dateDestroyed
oan contains borID(PH)*, bcID(OK)*, dateOut(FK), dateDue and dateBack
Publisher contains PubId(PK), pubName and pubAddress
Publisher cotains PubID(8), pubName, pubAddress
Authoer contains authorID(PK) and authorName
Authorship contains authorId*, and ISBN*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
编辑:看起来你的所有表格都是错误的。您的
JOIN
引用了FROM
语句中不存在的表EDIT2:看来您的
JOIN
要么是简单的连接,要么是语法不正确的更复杂的连接。请在此处研究JOIN
类型。对于简单的连接,请使用以下示例:编辑 3:检查 此处 和此处有关信息如何正确构建连接
Try this:
EDIT: It also appears all your tables are wrong. Your
JOIN
's are referring to tables that do not exist in yourFROM
statementEDIT2: It appears your
JOIN
's are either intended to be simple joins or are not properly syntax'd more complex joins. Please research here aboutJOIN
types. For a simple join use this example:EDIT 3: Check here AND here for info on how to build your joins properly
问题似乎出在第一行中的 AND 和 WHERE 子句中的“Loan”...您到底想做什么?
The problem appears to be with the AND in the first line and the "Loan" in the WHERE clause... What exactly are you trying to do?