SQLQuery错误

时间:2016-08-03 06:01:15

标签: sql

有人可以协助查询出了什么问题。错误是 信息156,第15级,状态1,第6行 关键字“FROM”附近的语法不正确。

SELECT TOP 1000 [SessionId]
WHERE [FONumber] = '156101'
AND [ShipTo] = '868257'
AND [OrderDate] = '2016-07-11'
FROM [NFConnect].[dbo].[tblOrders]

3 个答案:

答案 0 :(得分:2)

正确的语法是select ... from ..where

SELECT TOP 1000 [SessionId]
FROM [NFConnect].[dbo].[tblOrders]
WHERE [FONumber] = '156101'
AND [ShipTo] = '868257'
AND [OrderDate] = '2016-07-11'

答案 1 :(得分:0)

FROM应该在WHERE条款之前:

SELECT TOP 1000 [SessionId]
FROM [NFConnect].[dbo].[tblOrders]
WHERE [FONumber] = '156101'
AND [ShipTo] = '868257'
AND [OrderDate] = '2016-07-11'

答案 2 :(得分:0)

您必须在FROM

之前使用WHERE
SELECT TOP 1000 [SessionId]
FROM [NFConnect].[dbo].[tblOrders]
WHERE [FONumber] = '156101'
AND [ShipTo] = '868257'
AND [OrderDate] = '2016-07-11'

您可以在enter link description here

检查t-sql的语法
SELECT [ ALL | DISTINCT ]   
    [TOP ( expression ) [PERCENT] [ WITH TIES ] ]   
    < select_list >   
    [ INTO new_table ]   
    [ FROM { <table_source> } [ ,...n ] ]   
    [ WHERE <search_condition> ]   
    [ <GROUP BY> ]   
    [ HAVING < search_condition > ]