When I wrote the statement below, I encountered a problem that UNIQUE key word is not recognized and program says that "Incorrect syntax near the keyword 'UNIQUE'." How can I solve this problem?
当我写下面的语句时,我遇到了一个问题,即UNIQUE关键字无法识别,程序说“关键字'UNIQUE'附近的语法不正确。”我怎么解决这个问题?
SELECT FirstName, LastName
FROM CUSTOMER
WHERE UNIQUE
(SELECT CustomerID FROM SALES
WHERE SALES.CustomerID = CUSTOMER.CustomerID);
1 个解决方案
#1
1
There is no such use of WHERE
in SQL.
在SQL中没有使用WHERE。
See documentation for Search Condition.
请参阅搜索条件的文档。
You can count the rows from the sub-query and compare to 1:
您可以从子查询中计算行数并与1进行比较:
SELECT FirstName, LastName
FROM CUSTOMER
WHERE 1 = (SELECT count(CustomerID)
FROM SALES
WHERE SALES.CustomerID = CUSTOMER.CustomerID);
#1
1
There is no such use of WHERE
in SQL.
在SQL中没有使用WHERE。
See documentation for Search Condition.
请参阅搜索条件的文档。
You can count the rows from the sub-query and compare to 1:
您可以从子查询中计算行数并与1进行比较:
SELECT FirstName, LastName
FROM CUSTOMER
WHERE 1 = (SELECT count(CustomerID)
FROM SALES
WHERE SALES.CustomerID = CUSTOMER.CustomerID);