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

  • Learn T-SQL Querying
  • Pedro Lopes Pam Lahoud
  • 191字
  • 2021-06-24 14:38:10

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:

主站蜘蛛池模板: 唐海县| 湘西| 康保县| 什邡市| 江陵县| 仁化县| 博乐市| 贵州省| 灵丘县| 潮州市| 林州市| 沙雅县| 三河市| 信阳市| 涡阳县| 林甸县| 延寿县| 合阳县| 富川| 五常市| 锦州市| 蕉岭县| 隆安县| 新野县| 义乌市| 阳泉市| 油尖旺区| 石嘴山市| 安平县| 巩留县| 蒙自县| 米易县| 东至县| 白银市| 名山县| 梧州市| 瑞金市| 无锡市| 韶关市| 邳州市| 南川市|