Solved

SELECT comparing to entire column

Posted on 2004-10-15
2
241 Views
Last Modified: 2006-11-17
Hi.

I have a query I am trying to do that I can not figure out. Any help will be appreciated.

I am trying to compare records in two tables (property and hotel_specific). Some records will have a link (p.id = h.trav_id) but for some the "h.trav_id" is missing. I want the results of the query to show all the records that are NOT a match. I have tried the below query but it even returns records that do have a match.

SELECT DISTINCT p.id, p.name, c.country_name
FROM property p, countries c, hotel_specific h
WHERE p.country = c.country_code
AND c.country_rid IN (6)
AND p.id != h.trav_id

Any body have the answer?

Thanks.

T
0
Comment
Question by:td234
2 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 250 total points
ID: 12319992
Are you trying to get the properties that do not have a matching hotel?

SELECT p.id, p.name, c.country_name
FROM property p, countries c
LEFT JOIN hotel_specific h ON p.id = h.trav_id
WHERE p.country = c.country_code
AND c.country_rid IN (6)
AND h.trav_id IS NULL;
0
 
LVL 2

Author Comment

by:td234
ID: 12321237
That's it. Thanks.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now