DP-900 · Question #305
You have the following T-SQL statement. SELECT o.OrderNo, o.OrderDate, c.Address, c.City FROM Order AS o JOIN Customer AS c ON o.Customer = c.ID; What is the function of the ON clause?
The correct answer is B. to match data in the Customer table to data in the Order table. The ON clause in a SQL JOIN specifies the condition used to match rows between two tables. It defines the relationship between the joined tables.
Question
Options
- Ato update data in the Customer table
- Bto match data in the Customer table to data in the Order table
- Cto define an alias for the Customer table
- Dto update data in the Order table
How the community answered
(33 responses)- A3% (1)
- B88% (29)
- C3% (1)
- D6% (2)
Why each option
The ON clause in a SQL JOIN specifies the condition used to match rows between two tables. It defines the relationship between the joined tables.
The ON clause does not modify data; it is part of a SELECT statement's JOIN syntax and only evaluates a match condition - no DML operation occurs.
The ON clause specifies the join predicate that links rows from the Order table to rows in the Customer table. Here, it matches Order.Customer (foreign key) to Customer.ID (primary key), telling the database engine which rows from each table belong together in the result set.
Table aliases are defined using the AS keyword directly after the table name in the FROM or JOIN clause, not within the ON clause.
The ON clause performs no data modification on the Order table; it solely evaluates a Boolean condition to determine which rows to combine.
Concept tested: SQL JOIN ON clause join predicate
Source: https://learn.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql
Topics
Community Discussion
No community discussion yet for this question.