为什么我在“BYStock_Date”附近收到错误语法错误?

时间:2012-05-01 08:55:22

标签: sql sql-server sql-server-2005

我在此查询中遇到上述错误。

string query3 = "select Stock_Price,Stock_Quan_Met from Stock where Item_Id=(select ItemTileId from ItemTiles where ItemName=@itm) ORDER BY"+
            "Stock_Date ASC";

1 个答案:

答案 0 :(得分:3)

您的查询结果

select Stock_Price,Stock_Quan_Met from Stock where Item_Id=(select ItemTileId from ItemTiles where ItemName=@itm) ORDER BYStock_Date ASC

至少添加一个空格,你很好。

string query3 = "select Stock_Price,Stock_Quan_Met from Stock where Item_Id=(select ItemTileId from ItemTiles where ItemName=@itm) ORDER BY "+
            "Stock_Date ASC";