Re: Table compare
From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 04/21/04
- Next message: Greg O: "Re: data migration"
- Previous message: Dan Guzman: "Re: How to address an XML Element that contains a colon character?"
- In reply to: Steve C: "Re: Table compare"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 20 Apr 2004 22:24:44 -0500
> If I want to limit the choices to a smaller set, say a date range for
> instance, I must put the same range in both the main and
subquery....right?
If you want to filter on outer (Table1) criteria, you can do something like
the example below:
SELECT *
FROM Table1 AS t1
WHERE
t1.SomeDate BETWEEN '20040401' AND '20040420' AND
NOT EXISTS
(
SELECT *
FROM Table2 AS t2
WHERE t2.ID = t1.ID
)
-- Hope this helps. Dan Guzman SQL Server MVP "Steve C" <stevec@nospam.com> wrote in message news:%23hwE31uJEHA.3412@TK2MSFTNGP09.phx.gbl... > If I want to limit the choices to a smaller set, say a date range for > instance, I must put the same range in both the main and subquery....right? > > "Dan Guzman" <danguzman@nospam-earthlink.net> wrote in message > news:uLaIrYRHEHA.700@TK2MSFTNGP09.phx.gbl... > > You can use NOT EXISTS, NOT IN or LEFT JOIN. Personally, I prefer NOT > > EXISTS: > > > > SELECT * > > From Table1 AS t1 > > WHERE NOT EXISTS > > ( > > SELECT * > > FROM Table2 AS t2 > > WHERE t2.ID = t1.ID > > ) > > > > -- > > Hope this helps. > > > > Dan Guzman > > SQL Server MVP > > > > "Dave" <sysadmin@enaples.com> wrote in message > > news:uW83XPRHEHA.3952@TK2MSFTNGP10.phx.gbl... > > > Looking to find all records in one table that are not in another table. > > What > > > is the most efficient way? > > > > > > > > > > > >
- Next message: Greg O: "Re: data migration"
- Previous message: Dan Guzman: "Re: How to address an XML Element that contains a colon character?"
- In reply to: Steve C: "Re: Table compare"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|