[求助] MS SQL多表有相同字段查询的问题,请大家帮忙!
程序代码:[local]1[/local]SQL数据库:DATA
表Inventory_BigClass字段:
[local]2[/local]
表Inventory_SmallClass字段:
[local]3[/local]
两个表中有2个字段名Inventory_Number 、Warehouse 是一样的。
我的代码:
程序代码:
<!--#include file="Inc/conn.asp"--> <% sql="select a.Inventory_Number as Big_Number,a.Warehouse as Big_Warehouse,a.Head,a.riqi,b.Inventory_Number as Small_Number,b.Coding,b.Name,b.Specification,b.BigClass,b.SmallClass,b.Unit,b.Origin,b.Cost,b.Retail,b.Barcode,b.Warehouse as Small_Warehouse,b.Currently_Quantity,b.Inventory_Quantity,b.Remarks from Inventory_BigClass as a inner join Inventory_SmallClass as b on a.Inventory_Number=b.Inventory_Number" set rs=server.CreateObject("adodb.recordset") rs.open sql,conn,1,1 %> <table border="1" cellpadding="3" cellspacing="1"> <tr style="font-weight:bold;" align="center"> <td>单号</td> <td>仓库</td> <td>经手人</td> <td>日期</td> <td>商品编号</td> <td>商品名称</td> <td>规格型号</td> <td>大类</td> <td>小类</td> <td>单位</td> <td>产地</td> <td>成本价</td> <td>零售价</td> <td>商品条码</td> <td>商品仓库</td> <td>库存数量</td> <td>盘点数量</td> <td>备注</td> </tr> <% if rs.bof and rs.eof then response.Write("<table width=100% border=0>") response.Write("<tr>") response.Write("<td style=font-size:13px;color:#FF0000 height=100>对不起,没有找到您需要的记录!</td>") response.Write("</tr>") response.Write("</table>") else do while not rs.eof %> <tr> <td><%=rs("Big_Number")%></td> <td><%=rs("Big_Warehouse")%></td> <td><%=rs("Head")%></td> <td><%=rs("riqi")%></td> <td><%=rs("Coding")%></td> <td><%=rs("Name")%></td> <td><%=rs("Specification")%></td> <td><%=rs("BigClass")%></td> <td><%=rs("SmallClass")%></td> <td><%=rs("Unit")%></td> <td><%=rs("Origin")%></td> <td><%=rs("Cost")%></td> <td><%=rs("Retail")%></td> <td><%=rs("Barcode")%></td> <td><%=rs("Small_Warehouse")%></td> <td><%=rs("Currently_Quantity")%></td> <td><%=rs("Inventory_Quantity")%></td> <td><%=rs("Remarks")%></td> </tr> <% rs.movenext loop end if rs.close set rs=nothing conn.close set conn=nothing %> </table>
为什么 不行呢,请大家帮忙看看代码哪里出错了。谢谢!