Access数据库 ..
我有图书馆表格,其中 Autnm主题尺寸封面 外键
每个记录实际上都是一本书,其中包含作者和东西等属性。我不太确定我是否正在使用正确的JOIN ......对于“复杂的”SQL来说还是新的:)
SELECT Library.Bknm_Hebrew, Library.Bknm_English, Library.Bknm_Russian, Library.Note,
Library.ISBN, Library.Pages, Library.PUSD, Author.ID AS [AuthorID],
Author.Author_hebrew AS [AuthorHebrew],
Author.Author_English AS [AuthorEnglish],
Author.Author_Russian AS [AuthorRussian], Topic.ID AS [TopicID],
Topic.Topic_Hebrew AS [TopicHebrew], Topic.Topic_English AS [TopicEnglish],
Topic.Topic_Russian AS [TopicRussian], Size.Size AS [Size],
Cover.ID AS [CoverID], Cover.Cvrtyp_Hebrew AS [CoverHebrew],
Cover.Cvrtyp_English AS [CoverEnglish], Cover.Cvrtyp_Russian AS [CoverRussian],
Lang.ID AS [LangID], Lang.Lang_Hebrew AS [LangHebrew],
Lang.Lang_English AS [LangEnglish],
FROM Library INNER JOIN Author ON Library.Autnm = Author.ID
INNER JOIN Topic ON Library.Topic = Topic.ID
INNER JOIN Size ON Library.Size = Size.ID
INNER JOIN Cover ON Library.Cover = Cover.ID
INNER JOIN Lang ON Library.Lang = Lang.ID
WHERE (TopicID=13 AND LangID=1) ORDER BY LangID ASC
编辑:插入@Guffa建议的parantheses后,我收到了一个新错误:
Too few parameters. Expected 3.
答案 0 :(得分:15)
在Access中,如果您有多个联接,则需要括号。此外,正如Ivar所指出的,在字段列表中的最后一项之后还有一个额外的逗号。
select
Library.Bknm_Hebrew, Library.Bknm_English, Library.Bknm_Russian, Library.Note,
Library.ISBN, Library.Pages, Library.PUSD, Author.ID as [AuthorID],
Author.Author_hebrew as [AuthorHebrew], Author.Author_English as [AuthorEnglish],
Author.Author_Russian as [AuthorRussian], Topic.ID as [TopicID],
Topic.Topic_Hebrew as [TopicHebrew], Topic.Topic_English as [TopicEnglish],
Topic.Topic_Russian as [TopicRussian], Size.Size as [Size], Cover.ID as [CoverID],
Cover.Cvrtyp_Hebrew as [CoverHebrew], Cover.Cvrtyp_English as [CoverEnglish],
Cover.Cvrtyp_Russian as [CoverRussian], Lang.ID as [LangID],
Lang.Lang_Hebrew as [LangHebrew], Lang.Lang_English as [LangEnglish]
from
(((((Library
inner join Author on Library.Autnm = Author.ID)
inner join Topic on Library.Topic = Topic.ID)
inner join Size on Library.Size = Size.ID)
inner join Cover on Library.Cover = Cover.ID)
inner join Lang on Library.Lang = Lang.ID)
错误消息“参数太少”。表示您在查询中定义了参数,这些参数在执行时未发送。由于您不在查询中使用任何参数,这意味着您在查询中拼写了一些错误的名称,因此它认为它们是参数。
答案 1 :(得分:2)
我对Access不太熟悉,因此不确定它是否接受了这一点,但我首先要从选择列表中删除最后一个逗号。
Lang.Lang_English AS [LangEnglish], => Lang.Lang_English AS [LangEnglish]