Compartir a través de


Select Records from an Inner Join Sample

File: ...\Samples\Data\Innerj.qpr

The query, INNERJ, in the Solution project uses the database, TESTDATA, and combines information from the tables, ORDERS and CUSTOMER using an inner join condition. Each result record has fields for the CUST_ID, COMPANY, and COUNTRY from the CUSTOMERS table, and ORDER_ID from the ORDERS table as specified in the SELECT clause of the SELECT-SQL statement.

SELECT Customer.cust_id, Customer.company, Customer.country,;
 Orders.order_id;
 FROM testdata!orders INNER JOIN testdata!customer ;
 ON Orders.cust_id = Customer.cust_id

This query retrieves and combines the records between the two tables that match the join condition. The condition specifies that the records must have the same value in the cust_id field.

An inner join typically answers one basic question. In this query, the question is what orders did each customer place? If a customer has a record in the database but has not placed an order, the record does not appear in the results because it is not part of the subset that matches the join condition.

You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.

See Also

Tasks

Solution Samples

Other Resources

Views and Queries Solution Samples