|
-
Jan 11th, 2000, 03:15 PM
#1
Thread Starter
Lively Member
I'm using Microsoft Access 97.
Question:
there's 70 records in Qry1 and 25 records in Qry2.
25 records in Qry2 are identical to the records in Qry1.
SQL Statement:
"select * from Qry1, Qry2 where Qry1.Field1<> Qry2.Field2"
It returns 1750 records instead of only 55 records. It seems like the <> statement is not working. Why?? How do i get the 45 records which is in Qry1 but not in Qry2??
-
Jan 11th, 2000, 03:51 PM
#2
Guru
You get 1750 records because 25*70 = 1750 -- it will show each record where they are not equal in each record....
Try this (I didn't test it, but it should do)
Select * from Qry1 left join qry2 on qry1.field1 = qry2.field2 where qry2.field2 is null
I think that's right....yes?
-
Jan 11th, 2000, 07:30 PM
#3
Lively Member
-
Jan 11th, 2000, 11:38 PM
#4
Thread Starter
Lively Member
Thanks firstKnight...
The statement works perfectly if it's an "=".
But when you use "<>", it first join those 2 tables together and create a new recordset with 1750 rows. When you use the "<>" statement with the distinct statement, all the 70 rows will come out...if you don't use the distinct statement, then 1725 rows will be in the query...
I haven't tested the statement from Clunietp.
I'll try it tomorrow in the office.Thanks.
-
Jan 11th, 2000, 11:52 PM
#5
Frenzied Member
Karl Moore's database tutorial.... is that on the internet? If so where can I find it?
Thx.
-
Jan 12th, 2000, 01:27 AM
#6
Guru
by using an INNER JOIN, you will display all records that are in both tables.
by using a LEFT JOIN, you will see all records in table1 and a corresponding matching record from table2 if there is one, otherwise you will get a null for the table2 fields. (which is what I specified as a condition, so we get the ones that DO NOT have a match in the second table)
the use of the LEFT JOIN will give lychew what he needs to get done, inner join will not help him here.
lychew wants the records that DO NOT have a match in table2. If he wanted a match, INNER JOIN is the winner.
-
Jan 12th, 2000, 03:39 AM
#7
Lively Member
*grins*
The easiest way to do this is Clunie's.
If you want a step-by-step method, however, go to Query, New, Find Unmatched Wizard.
This will walk you through step by step.
The end result, however, will be Clunie's SQL statement.
-
Jan 12th, 2000, 08:59 AM
#8
Thread Starter
Lively Member
Thanks guys.
Both the methods work perfectly.
-
Jan 12th, 2000, 02:49 PM
#9
Lively Member
-
Jan 16th, 2000, 02:44 PM
#10
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|