Not equal [!=] link – HP Intelligent Management Center Standard Software Platform User Manual

Page 694

Advertising
background image

Not Equal [!=] link

The result set from a Not Equal link includes all records in which the linked
field value in the primary table is not equal to the linked field value in the
lookup table. This type of link can be used to find possible combinations of
items when a table is joined to itself (a self-join). For example, a company
can have a table listing all products they sell. When they decide to hold a
sale where their customers buy one item and get the second item half price,
they may need a list of all possible two item combinations:

SELECT Product1.'Product Name',

Product2.'Product Name',

FROM 'Product' Product1

'Product' Product2

WHERE Product1.'Product Name' !=

Product2.'Product Name'

In this SQL statement, the Product table is opened twice. The first time, it is
given the alias name Product1. The second time, it is given the alias name
Product2. Then the Product Name field is used to link from the Product1
table to the Product2 table. This is the same table, but since it has been
opened twice using different aliases, Crystal Reports considers it two separate
tables. A Not Equal link is used to link the tables by the Product Name field.
As a result, each product is paired with every other product offered, but is
not paired with itself:

Product2

Product1

Product Name

Product Name

Xtreme Mtn Lock

Xtreme Adult Helmet

InFlux Lycra Glove

Xtreme Adult Helmet

Roadster Micro Mtn Saddle

Xtreme Adult Helmet

694

Crystal Reports 2008 SP3 User's Guide

Understanding Databases

25

Linking tables

Advertising