Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 的用法 » 查询和修改数据 » 连接:从多个表检索数据 » 显式连接条件(ON 子句)

 

显式连接条件的类型

大多数连接条件都是基于等同性的,因此称作等值连接。例如,

SELECT *
FROM Departments JOIN Employees
   ON Departments.DepartmentID = Employees.DepartmentID;

但是,您并非一定要在连接条件中使用等号 (=)。您可以使用任何搜索条件,例如包含 LIKE、SOUNDEX、BETWEEN、>(大于)和 !=(不等于)的搜索条件。

示例

以下示例回答的问题是:哪些产品的订购数量大于库存数量?

SELECT DISTINCT Products.Name
FROM Products JOIN SalesOrderItems
ON Products.ID = SalesOrderItems.ProductID
   AND SalesOrderItems.Quantity > Products.Quantity;

有关搜索条件的详细信息,请参见搜索条件