Ask a Question related to ASP Database, Design and Development.
-
Shawn #1
Unmatched records from Join
I have 2 tables.
table1: ssn, name, date, status
table2: ssn, name, dept
I wanted to know if there is it possible to get all the
unmatched records from either table. I want all the ssn's
that do not have matches. Is that possible? I tried with
an right/left outer join but it returns matches and
unmatched. Thanks.
Shawn Guest
-
Is left-join faster then inner join?
Some people said that using left-join is generally faster than inner join, is that true? Thanks... -
JOIN vs no JOIN
Is there any benefit in doing: SELECT a.f1, a.f2, b.f3 FROM t1 a INNER JOIN t2 b ON a.f1=b.id WHERE a.f1> 0 rather than SELECT a.f1, a.f2,... -
Is self-join appropriate?
Please forgive me if this post is too long. I was trying to solve this (probably simple) issue for all day but I'm not as good in SQL as I thought... -
Querying for unmatched records in two tables
I have two tables - One contains a list of all the zip codes in the US. The other table is basically a mailing list containing addresses of people... -
[Q] Self join portal records - why one too many?
Using FMP 6.04 dev under MacOS X 10.2.6 I have a self-join working just fine with the desired records appearing in the portal but there is one... -
Ray at #2
Re: Unmatched records from Join
SELECT [ssn],[name],[date],[status] FROM [table1] WHERE [ssn] NOT IN (SELECT
[ssn] FROM [table2])
Ray at work
"Shawn" <sfergus2@cscc.edu> wrote in message
news:469301c37bbd$00552000$a601280a@phx.gbl...> I have 2 tables.
> table1: ssn, name, date, status
> table2: ssn, name, dept
> I wanted to know if there is it possible to get all the
> unmatched records from either table. I want all the ssn's
> that do not have matches. Is that possible? I tried with
> an right/left outer join but it returns matches and
> unmatched. Thanks.
>
>
Ray at Guest
-
Nicole Calinoiu #3
Re: Unmatched records from Join
Shawn,
A full outer join will do this for you. e.g. (SQL Server syntax):
SELECT A.SSN AS SSN_1, B.SSN AS SSN_2
FROM
Table1 AS A
FULL OUTER JOIN Table2 AS B
ON A.SSN = B.SSN
WHERE (A.SSN IS NULL) OR (B.SSN IS NULL)
If your db platform does not support full outer joins, you'll need to UNION
two separate outer joins. e.g. (Access syntax):
SELECT A.SSN AS SSN_1, B.SSN AS SSN_2
FROM
Table1 AS A
LEFT JOIN Table2 AS B
ON A.SSN = B.SSN
WHERE B.SSN IS NULL
UNION
SELECT B.SSN AS SSN_1, A.SSN AS SSN_2
FROM
Table2 AS A
LEFT JOIN Table1 AS B
ON A.SSN = B.SSN
WHERE B.SSN IS NULL
HTH,
Nicole
"Shawn" <sfergus2@cscc.edu> wrote in message
news:469301c37bbd$00552000$a601280a@phx.gbl...> I have 2 tables.
> table1: ssn, name, date, status
> table2: ssn, name, dept
> I wanted to know if there is it possible to get all the
> unmatched records from either table. I want all the ssn's
> that do not have matches. Is that possible? I tried with
> an right/left outer join but it returns matches and
> unmatched. Thanks.
>
>
Nicole Calinoiu Guest
-



Reply With Quote

