这有什么问题?我想列出这些项where material number from mm = Child_Material_Number From bom and Parent_Material_Number = ' '
。
这是我的代码:
rs.open("SELECT Material_Number,Material_Descr_HU FROM mm m" & _
" WHERE " & _
"Child_Material_Number FROM bom" & _
" = Material_Number FROM mm) " & _
"AND Parent_Material_Number = ''",
cn, _
ADODB.CursorTypeEnum.adOpenKeyset, _
ADODB.LockTypeEnum.adLockOptimistic _
)
答案 0 :(得分:0)
在SQL中,子句FROM告诉服务器在搜索数据时要查看哪些表或查询。您正在寻找的查询是这样的:
SELECT mm.Material_Number, mm.Material_Descr_HU
FROM mm INNER JOIN bom
ON mm.Material_Number = bom.Child_Material_Number
WHERE bom.Parent_Material_Number = ''
另外,始终要记住基本的SQL语句结构,即:
SELECT [fields]
FROM [tables or queries]
WHERE [condition]
ORDER BY [fields]
您的查询中的问题是您在WHERE子句之后和之内包含FROM子句。 当然,你可以这样做 - 以及更多 - 如果你正在嵌套查询,但是你需要第二个SELECT子句。
有很多SQL教程,如果您计划将来使用数据,它们值得一看。