473,383 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

I want a query to find all entries on table1 without a corresponding entry on table2

I have two tables of town names , in one table the spellings are correct(table x) whilst on the other there are some mistakes (table y).

I would like to run a query that will read table y and tell me all entries on it which do not have a match on table x - the towns must also be in the same county, detailes below

CREATE TABLE X
(
ID NUMBER,
NAME VARCHAR2(100 BYTE),
COUNTY_ID VARCHAR2(100 BYTE),
RATING_AREA VARCHAR2(100 BYTE),
RATING_AREA_CODE VARCHAR2(100 BYTE),
CODE_ID INTEGER
)

CREATE TABLE Y
(
ID NUMBER(10),
DESCRIPTION VARCHAR2(40 BYTE),
COUNTY_ID NUMBER(10),
ISN VARCHAR2(7 BYTE),
RATING_CODE NUMBER(10),
HOME_RATING_CODE NUMBER(10)
)

CREATE TABLE COUNTY
(
ID NUMBER(10),
DESCRIPTION VARCHAR2(40 BYTE),
RATING_CODE NUMBER(10),
HOME_RATING_CODE NUMBER(10)
)

the name field in table x should correspond with the description field in table Y, but Y are in upper case whilst X is in sentence case - the county_id on table X (which is the county name) should match the name held on a county file with an ID matching the County_ID on the Y file , the county file names are in upper case as opposed to the county name on X being in sentence

can anyone tell me what the best way to get the desired result would be

Thanks

LT
Nov 13 '08 #1
5 1891
Pilgrim333
127 100+
Hi,

What have you tried so far? At what part did you get stuck?

Pilgrim
Nov 13 '08 #2
debasisdas
8,127 Expert 4TB
you need to join the tables baseed on fields that you want to compare.
Nov 13 '08 #3
what I have tried so far is the following

select Y.DESCRIPTION from Y minus select UPPER (X.NAME) from X;

the problem with this is that if a town appears in more than one county then it does not check the town and county combination from file X is the same as in file Y , so if I have ballyboggin in county dublin on file Y but on file X it matches to a ballyboggin that is in county cork the above will not report this - this would be an issue if the correct spelling of the dublin town was ballybogin
Nov 14 '08 #4
Saii
145 Expert 100+
did you try using "not exists"?
Nov 14 '08 #5
QVeen72
1,445 Expert 1GB
Hi,

You can also Try NOT IN:

Select * From Table1 Where Col1 Not IN (Select MyCol From Table2)

Regards
Veena
Nov 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
0
by: krystoffff | last post by:
Hi all For speed reasons, I would like to rewrite the following query without the subquery : SELECT * FROM table1 WHERE field1 NOT IN (SELECT field1 FROM table2 where field2=X); I thought...
3
by: connections cardiff | last post by:
hi all, could someone convert english->MySQL please? show me all the records in database1.table1 where there is no corresponding record in database1.table2 comparing by fieldx to recap: ...
3
by: JC Mugs | last post by:
Help needed for project-Access 2002(office xp) PROBLEM: Figuring out how to lookup a record and DDate field in Table1 - Take that DDate-field data from record looked up and assign it to Date...
5
by: Jack | last post by:
Hi, I am trying to find rows where a memo field in table1 contains the text in table2. Example: table1.memo contains: row 1: This is a long sentence that goes on and on... row 2: This is...
1
by: Jon | last post by:
Hi there. I'm trying to create a query (or two) that I can use to produce a spreadsheet but I'm having a bit of trouble. I'm using Access 2000. My db is set up like this: Table1: Intrusive...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
6
Plater
by: Plater | last post by:
(I don't even know how to title this) The bossman says I need to add a certain field into a query and I have yet to figure out out to do it. I will try and make a trimmed down example. ...
2
by: sharsy | last post by:
Hello, I have a Database setup that has two tables that are linked. Table1 contains a list of people with their basic contact details (name & phone number etc.) and Table2 contains a list of all...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.