[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SELECT comparing to entire column

Posted on 2004-10-15
2
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 1000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

656 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