我正在尝试在MS Access 2010
中编写SQL代码,如下所示: -
select WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
运行代码后,Access在指向第四行的selects PrintPromotions
任何反馈都将受到赞赏..
谢谢。
答案 0 :(得分:1)
应该是PrintPromotions而不是PrintPromtions吗?
答案 1 :(得分:0)
这很好,因为where子句是对整个集合的评估。
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
LEFT join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
这将排除不在wowPerformanceData_tbl中的printPromotions中的记录,这会破坏正确的连接。:
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
where (WOWPerformanceData_tbl.Style=[Enter Style nr:]);
这样做是为了保留PrintPromotions中的所有记录以及wowperofrmanceData_tbl中匹配的记录。
SELECT WOWPerformanceData_tbl.Style,
WOWPerformanceData_tbl.FY,
WOWPerformanceData_tbl.Month,
PrintPromotions.[Type of Offer],
PrintPromotions.Start,
PrintPromotions.End
from WOWPerformanceData_tbl
right join PrintPromtions
on WOWPerformanceData_tbl.Style=PrintPromotions.Style
AND (WOWPerformanceData_tbl.Style=[Enter Style nr:]);