官术网_书友最值得收藏!

WHERE

The WHERE clause specifies the search condition that determines whether a row should be returned in the result set. Rows will be returned only if the entire WHERE clause evaluates to TRUE. Each condition within the WHERE clause is referred to as a predicate. There is no limit to the number of predicates that can appear in a WHERE clause, and predicates are combined using the AND, OR, and NOT logical operators.

For example, the AdventureWorks sample database has a Product table that contains the Name and ProductID columns, a ProductInventory table that contains the Quantity, LocationID, and ProductID columns, and a Location table that contains the LocationID and Name columns. A query that returns the current product inventory per location, for the entire Touring line of products would look like the following code block:

SELECT P.Name AS ProductName, [PI].Quantity, L.Name AS LocationName
FROM Production.Product AS P
INNER JOIN Production.ProductInventory AS [PI] ON P.ProductID = [PI].ProductID
INNER JOIN Production.Location AS L ON [PI].LocationID = L.LocationID
WHERE P.Name LIKE 'Touring%';

The following screenshot shows that all the ProductName values in the result set begin with the word Touring:

主站蜘蛛池模板: 偏关县| 恩平市| 成安县| 杭州市| 武邑县| 佛山市| 安达市| 泸定县| 沭阳县| 江门市| 兴安盟| 临朐县| 沙湾县| 黑龙江省| 通辽市| 信阳市| 丹巴县| 江达县| 平泉县| 天长市| 聊城市| 富民县| 合作市| 云浮市| 吴川市| 北安市| 浠水县| 平昌县| 安龙县| 枝江市| 肇州县| 朔州市| 永年县| 象州县| 双流县| 沈丘县| 上饶市| 兴海县| 德格县| 平果县| 青州市|