First page Back Continue Last page Image

A Self-Join – And an example of Multiple Join Criteria

SELECT DISTINCT v1.vendor_name, v1.vendor_city,

v1.vendor_state

FROM vendors v1 JOIN vendors v2

ON v1.vendor_city = v2.vendor_city AND

v1.vendor_state = v2.vendor_state AND

v1.vendor_name <> v2.vendor_name

ORDER BY v1.vendor_state, v1.vendor_city

Here we are joining a table with itself in order to compare the data in the table to other data in the same table

In this example we wanted to see all the vendors in the same area (City)