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

  • 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:

主站蜘蛛池模板: 蒙自县| 汶川县| 安乡县| 新乐市| 娄烦县| 山丹县| 宣化县| 阳泉市| 连山| 类乌齐县| 张掖市| 洛宁县| 河北省| 平昌县| 潍坊市| 东台市| 易门县| 蚌埠市| 阿图什市| 铜梁县| 连城县| 巴青县| 开化县| 津南区| 崇仁县| 如东县| 荥经县| 永修县| 昌吉市| 凉城县| 宜宾市| 沂源县| 进贤县| 财经| 晋中市| 太保市| 普安县| 运城市| 东乡族自治县| 乌拉特中旗| 开远市|