473,385 Members | 1,673 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,385 software developers and data experts.

"not like" query results in extra rows being removed

I'm a novice at Access and am having trouble with a Not Like query. I'm trying to remove rows with the term "Accrual" from a table. I know there are 16 rows that have the term Accrual, but when I do a Not Like "Accrual" query it removes 80 rows. If I change the query to Like "Accrual" it will show the 16 rows. Why is the Not Like query removing more rows?

I appreciate any help/guidance for this rookie.
Apr 11 '10 #1
3 2490
missinglinq
3,532 Expert 2GB
In the Query Design Grid, in the field's Criteria, use

<>"Accrual"

The SQL, assuming the field in question is called TargetField, would be
Expand|Select|Wrap|Line Numbers
  1. SELECT YourTableName.Field1, YourTableName.Field2, YourTableName.TargetField
  2. FROM YourTableName
  3. WHERE (((YourTableName.TargetField)<>"Accrual"));
Welcome to Bytes!

Linq ;0)>
Apr 11 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
From what your describing, im guessing the field with the value "Accrual" also contains records that are null. You can read more about querys with fields that can be null elsewhere, but the quick fix to your issue:

Change the criteria to:
<> "Accrual" Or Is Null
Apr 12 '10 #3
NeoPa
32,556 Expert Mod 16PB
When you use "Like" (or "Not Like") then you need to use some wildcard characters. Otherwise it is equivalent to = (or Not =). Your current SQL is really saying :
Expand|Select|Wrap|Line Numbers
  1. "<>'accrual'"
If you'd like to specify all records where a particular field doesn't contain the string "accrual", then you need something like :
Expand|Select|Wrap|Line Numbers
  1. WHERE [FieldName] Not Like '*accrual*'
Also check out ANSI Standards in String Comparisons for a full understanding of which characters to use for this in your situation.
Apr 12 '10 #4

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

Similar topics

5
by: NK | last post by:
Hi all, Does anyone know of how I can disable case sensitivity for the LIKE function in SQL? Currently the SQL statement looks like: $query = "SELECT * FROM itrader_games WHERE...
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
3
by: Branco Medeiros | last post by:
Hi all, Using SQL Server 2000, SP4. I have a table of street names (Rua) whose ids (cod_rua) are foreign keys into a consumer table (Consumidor). It turns out that the "Rua" table has many...
11
by: Bruce Lawrence | last post by:
Ok, I'm baffled... I'm making a query in access 97 between 2 tables. There is a field in both tables called "DWGNO". OPENORD has a record with a DWGNO of "00000012345" DIEDATA has a record...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
5
by: brino | last post by:
hi all ! i want to use the "like" function in a query but i want the user to enter the search variable. i have tried "like" but this doesnt return any results for some reason. any ideas ??? ...
13
by: ThePrinceIsRight | last post by:
I have a problem with using a subquery in MS Access. The purpose of the sub-query is to create a list of people who have had doctor exams in the past 6 months and exclude them from the main query....
1
by: Aegixx | last post by:
Ok, extremely wierd situation here: (I'll post the code below, after the explanation) I've got a Windows application (.NET 3.5) that has a single Form with a DataGridView embedded. The user...
4
by: emanning | last post by:
I'm having problems using "<>" as criteria for a varchar column in a view. The data in this column is '2008-2009' which is supposed to mean year 2008 thru 2009. If I set the criteria to "=...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.