Re: Exclude records that meet criteria
- From: david <david@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Feb 2007 12:02:00 -0800
This thread was started in 2004. I have learned a few extra things since then.
In order not to have NULL value mess up your queries (for instance in the
where clause, etc, ...), place the following statements in the body of your
stored procedure or query:
-----------------------------------
set ANSI_NULLS OFF
SET CONCAT_NULL_YIELDS_NULL OFF
-----------------------------------
For more info, do a help and search for the above from within MS SQL.
David
2/27/07
"Christian" wrote:
Hi,.
I have tried it, but when I tested, it worked with the "In (SELECT...)" to
include those records, but it didn't work with the "Not in (SELECT...) to
exclude the records.
It took me a while to figure out why.
It is important to mention that if the field used in the subquery has Null
values, those values must be excluded in the subquery criteria, otherwise,
the main query will never return anything.
Something like "Not In (SELECT FIELDNAME FROM Tablename WHERE FIELDNAME Is
Not Null...)
I hope this might help someone else with the same problem.
Kind regards,
"David" wrote:
Hi Nikos,
Thank you for the response.
I have tried and it works.
Regards,
David
"Nikos Yannacopoulos" wrote:
David,
If I understand this right, you want a query which will reurn records with
FirstNames which do not exist in the other table?
If this is the case, use a subquery on the second table in the criteria
under the FirstName field of table A, like:
Not In (SELECT FirstName FROM [Table B])
Just change the table and field names to the actual ones, and it should do
the job.
Likewise, omitting the Not at the beginning would return records with common
first names.
HTH,
Nikos
"David" <David@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FB98EDC6-77DF-4C5B-B395-C55881B8BB8E@xxxxxxxxxxxxxxxx
Hi,querry
In a select querry, records the meet criteria are normally included in the
selection.
However, I need to do just the opposite.
I need to exclude rather than include records from a table that meet
criteria.
Can anyone tell me how this may be accomplished?
Note: The criteria I used simply compares a field in the main table (whose
records I want to prune) with a field in a second table. (e.g. check if
"FirstName" in Table A is the same as "FirstName" in Table B.)
Also, if you suggest a solution that involves Visual Basic coding, I would
appreciate you also provide a sample code that I may modify.
I am new to very new to Visual Basic.
Thanks.
David
- Follow-Ups:
- Re: Exclude records that meet criteria
- From: david
- Re: Exclude records that meet criteria
- References:
- Re: Exclude records that meet criteria
- From: Christian
- Re: Exclude records that meet criteria
- Prev by Date: Copy Method
- Next by Date: Re: import a range in a column to an access table
- Previous by thread: Re: Exclude records that meet criteria
- Next by thread: Re: Exclude records that meet criteria
- Index(es):
Relevant Pages
|