Solved

Access 2007 - Query syntax

Posted on 2011-09-08
25
253 Views
Last Modified: 2012-05-12
My OS is windows 7 and I use Access 2007.  The table has a marker field which is a text type, and some of the records are marked with X.  I would like to retrieve all the records that do not have an X.  What is the syntax please.  I tried <>X; !=X; NOT X, but they all do not work.  Looks like I am having the wrong syntax.  Thank u.
0
Comment
Question by:jegajothy
  • 12
  • 9
  • 3
  • +1
25 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 36506359
How about
select * from foo where bar <> 'X'

Open in new window

0
 
LVL 47

Accepted Solution

by:
for_yan earned 333 total points
ID: 36506366


http://office.microsoft.com/en-us/access-help/examples-of-query-criteria-HA010066611.aspx

it says Not Like "*X*"

or Not "X"

if you cannot have "X1" or something

0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 333 total points
ID: 36506382
It looks like in your experiments you were not using quotes - but they are necessary - in the examples in the link above they are double quotes;
perhaps single quotes may work either
0
 

Author Comment

by:jegajothy
ID: 36506419
In response to CEHJ, the above does not work.
I have  this in the syntax :
SELECT [tblOct-Nov-Dec 2011].*
FROM [tblOct-Nov-Dec 2011]
WHERE Marker <> 'X';

Marker is the name of the Text type field.  Thank u for your response.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36506431
Try double quotes - maybe it will work ?
0
 

Author Comment

by:jegajothy
ID: 36506437
I tried this too and it does not work :
SELECT *
FROM [tblOct-Nov-Dec 2011]
WHERE ((([tblOct-Nov-Dec 2011].Marker)<>'X'));
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36506537
Try
SELECT * FROM "tblOct-Nov-Dec 2011" WHERE "tblOct-Nov-Dec 2011.Marker" <>'X'

or

SELECT * FROM "tblOct-Nov-Dec 2011" WHERE "tblOct-Nov-Dec 2011".Marker <>'X'

Open in new window

0
 

Author Comment

by:jegajothy
ID: 36506673
In response to everyone, I have tried all one by one, and none seem to work.  thanks.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36506684
Maybe the bes way is to create a simple query in Access itseklf and then exxport its SQL
Though I'm not sure it is easy to do tyhe last step in Access - it is some obscure option in the menu I guess
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36506789


That is how I exported from MS Access (as it created itself) and the query works:
("Mailing List" is  table name)


I have MSAccess 2003 but it is the same thing I hope
SELECT [Mailing List].FirstName
FROM [Mailing List]
WHERE ((([Mailing List].FirstName)<>"X"));

Open in new window

0
 

Author Comment

by:jegajothy
ID: 36506900
in response to for yan, here is my syntax, hope u can review if I made any typos or not, but it did not product any results :
SELECT [tblOct-Nov-Dec 2011].MARKER
FROM [tblOct-Nov-Dec 2011]
WHERE ((([tblOct-Nov-Dec 2011].MARKER)<>"X"));
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36506921
The other table name contains hyphens and spaces though
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 47

Expert Comment

by:for_yan
ID: 36506929
Yes seems exact but I exported it from acces and it worked - maybe you don't have X
0
 
LVL 5

Assisted Solution

by:slycoder
slycoder earned 167 total points
ID: 36507057
Try:

SELECT [tblOct-Nov-Dec 2011].*
FROM [tblOct-Nov-Dec 2011]
WHERE ((([tblOct-Nov-Dec 2011].MARKER) Not Like "*X*"));

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36507081
Can you try to make a test table with more conventional name and try the query I posted?
0
 

Author Comment

by:jegajothy
ID: 36507123
In response to for yan, I changed  the name of the table but left the field Marker as it is.
and I tried these :
These do not work :
SELECT tblWithoutX.mARKER
FROM tblWithoutX
WHERE (((tblWithoutX.mARKER)<>"X"));

SELECT tblWithoutX.mARKER
FROM tblWithoutX
WHERE (((tblWithoutX.mARKER) Not Like "X"));
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36507247
Can yoi open MDB with access and try to run this query manually?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36507250
I mean through normal Access interface?
0
 

Author Comment

by:jegajothy
ID: 36510116
In response to for yan, I open Access and then highlight the MDB file and open it.
Thence I run the query, after modifying it.
If that is what u mean.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36510183
So you run it without SQL - just like normal MS Access users do, through visual inteface?
And does it return stuff which you expect?
0
 

Author Comment

by:jegajothy
ID: 36516644
in rersponse to for yan, the answer is No.  I do not get any results.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36516738
Then probably there are no rows in your table which satisfy this conditiion ?
0
 

Author Comment

by:jegajothy
ID: 36533229
in response to for yan, there are row with X, because when I run with field=X, I get results.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36533261
But are there rows which do not staisfy field = 'X' annd if there are such why you are bnot finding them even with
GUI based Access?
0
 

Author Closing Comment

by:jegajothy
ID: 36540368
thank u everyone.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 45
the whoisactive update 12 39
tomcat not starting 6 31
Error in @AspectJ Based AOP with Spring 2 0
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now