我正在使用VB.Net连接到SQL Server 2008
此作品 - > Dim query =“SELECT wo.WorkOrderID,wo.WorkOrderNo FROM dbo.WorkOrder wo”
这不起作用 - > Dim query =“SELECT wo.WorkOrderID,wo.WorkOrderNo,wod.LineNo FROM dbo.WorkOrder wo,dbo.WorkOrderDetails wod”
这也不起作用 - > Dim query =“SELECT wo.WorkOrderID,wo.WorkOrderNo,wod.LineNo FROM dbo.WorkOrder wo,dbo.WorkOrderDetails wod WHERE wo.WorkOrderID = wod.WorkOrderID“
我假设它,因为在WorkOrderDetails中,WorkOrderId具有多个相同的ID
有关如何使其发挥作用的任何想法?我无法理解......
我刚试过这个 - > “SELECT WorkOrderID,WorkOrderNo,LineNo FROM dbo.WorkOrder JOIN dbo.WorkOrderDetails ON dbo.WorkOrder.WorkOrderID = dbo.WorkOrderDetails.WorkOrderID”
似乎没有工作..同样的错误
答案 0 :(得分:4)
LineNo
是reserved keyword。使用Delimited Identifier。
SELECT WorkOrderID, WorkOrderNo, [LineNo]
FROM dbo.WorkOrder
JOIN dbo.WorkOrderDetails
ON dbo.WorkOrder.WorkOrderID = dbo.WorkOrderDetails.WorkOrderID
答案 1 :(得分:0)
使用join:
Dim query =
"SELECT wo.WorkOrderID,
wo.WorkOrderNo,
wod.[LineNo] FROM dbo.WorkOrder wo
JOIN dbo.WorkOrderDetails wod
ON wo.WorkOrderID = wod.WorkOrderID"
此网站将帮助您开始:
最佳观点