Hi everyone.
I have this query ASP and Db Access: - strSql = "SELECT Last(ID) AS ID, " &_
-
"A, " &_
-
"B, " &_
-
"C, " &_
-
"COUNT(D) AS TotD, " &_
-
"Last(D) AS D, "&_
-
"Last(E) AS E, " &_
-
"Last(date) AS date, "&_
-
"Last(tot) AS tot, "&_
-
"Last(MonthName) AS MonthName, "&_
-
"Last(IDMonth) AS IDMonth "&_
-
"FROM tbl "&_
-
"WHERE " &_
-
"(" &_
-
"(" &_
-
"(IDMonth = 12) OR " &_
-
"(IDMonth = 1) OR " &_
-
"(IDMonth = 2) OR " &_
-
"(IDMonth = 3) " &_
-
") " &_
-
"AND " &_
-
"(DATE > #2007/12/01#) " &_
-
"AND " &_
-
"(tot = 0) " &_
-
"OR " &_
-
"(EX = 'KO') " &_
-
"AND " &_
-
"(D NOT IN ('SA')) " &_
-
"AND " &_
-
"(" &_
-
"(E = 'NT') " &_
-
")) " &_
-
"GROUP BY D, A, B, C "&_
-
"HAVING " &_
-
"((COUNT(D)) = 5) " &_
-
"ORDER BY ID asc"
The query no error, but extract from the table access all values in the field "E".
Extraction should value equal to E = 'NT'
Can you help me ?
13 1848
Hi mike1961,
The problem is your OR condition. You need to be careful when using an OR to surround the conditions with brackets. For example: - WHERE A = 1 AND B = 2 AND (C = 3 OR C = 4)
Will return different results to - WHERE A = 1 AND B = 2 AND C = 3 OR C = 4
Let me know how you get on.
Dr B
Thanks moderator for you reply.
I have this response.write query:
[php]
SELECT Last(ID) AS ID, A, B, C, COUNT(D) AS TotD, Last(E) AS E, Last(F) AS F, Last(date) AS date, Last(tot) AS tot, Last(MonthName) AS MonthName, Last(IDMonth) AS IDMonth FROM tbl WHERE (((IDMonth = 12) OR (IDMonth = 1) OR (Month = 2) OR (IDMonth = 3) ) AND (DATE > #2007/12/01#) AND (tot = 0) AND (EX = 'KO') AND (D NOT IN ('SA')) AND ((E = 'NT') )) GROUP BY D, A, B, C HAVING ((COUNT(D)) = 5) ORDER BY ID asc
[/php]
In th DB Access I have rows whit EX = 'KO' AND E = 'NT' but this query not extract this rows...
Have you got Query Analyser or something similar you can run this query in to test it? If so, do that and comment out your conditions one by one until you get the data returned you are expecting. That way you'll see where the problem is.
I would hazard a guess that the problem is the AND (D NOT IN ('SA')) line so start with that.
Let me know how it goes,
Dr B
Nothing, not working... :(
[php]
SELECT Last(ID) AS ID, A, B, COUNT(D) AS TotD, Last(E) AS E, Last(F) AS F, Last(date) AS date, Last(tot) AS tot, Last(EX) AS EX, Last(MonthName) AS MonthName, Last(IDMonth) AS IDMonth FROM tbl WHERE (((IDMonth = 12) OR (IDMonth = 1) OR (Month = 2) OR (IDMonth = 3) ) AND (DATE > #2007/12/01#) AND (tot = 0) AND (EX = 'KO') AND ((E = 'NT') )) GROUP BY D, A, B HAVING ((COUNT(D)) = 4) ORDER BY ID asc
[/php]
Comment out all your conditions.....presumably the data you are expecting to see will display now?
Then start putting the conditions back in one by one and see which one is preventing your data from displaying.
Dr B
Comment out all your conditions.....presumably the data you are expecting to see will display now?
Then start putting the conditions back in one by one and see which one is preventing your data from displaying.
Dr B
OK.
I try this query in the DB Access.
Query working, but I would like see the field "EX"; now no see the field "EX".
[php]
SELECT tbl.A, tbl.B, tbl.C, Count(tbl.D) AS TotD
FROM tbl
WHERE (((tbl.IDMonth)=12 Or (tbl.IDMonth)=1 Or (tbl.IDMonth)=2 Or (tbl.IDMonth)=3) AND ((tbl.DATE)>#12/1/2007#) AND ((tbl.TOT)=0) AND ((tbl.E)='NT'))
GROUP BY tbl.A, tbl.B, tbl.C
HAVING (((Count(tbl.D))=4))
ORDER BY tbl.A;
[/php]
Nothing?
Help me please....
I'm not sure what you mean......if you want to see the field EX then you need to include it in your SELECT statement e.g. SELECT EX
Or am I missing something here?
Dr B
I'm not sure what you mean......if you want to see the field EX then you need to include it in your SELECT statement e.g. SELECT EX
Or am I missing something here?
Dr B
But if I include in the SELECt statement the field EX, I have:
[php]
SELECT tbl.A, tbl.B, tbl.C, tbl.EX, Count(tbl.D) AS TotD
FROM tbl
WHERE (((tbl.IDMonth)=12 Or (tbl.IDMonth)=1 Or (tbl.IDMonth)=2 Or (tbl.IDMonth)=3) AND ((tbl.DATE)>#12/1/2007#) AND ((tbl.TOT)=0) AND ((tbl.E)='NT'))
GROUP BY tbl.A, tbl.B, tbl.C, tbl.EX
HAVING (((Count(tbl.D))=4))
ORDER BY tbl.A;
[/php]
The result of query is 109 rows and not see the field EX; without field EX the result of query is 126 rows...
which is the right result ?
Is EX null in some of your rows?
Is EX null in some of your rows?
Yes, the field EX is always null...
It's always null? If it never contains any data then how come you want to SELECT it?
It's always null? If it never contains any data then how come you want to SELECT it?
In the DB access is not NULL... this query write NULL...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: david liu |
last post by:
access 2000 query:
here's what i want to do. from an asp page, perform a search on a
table in access. i have used sql code in the asp page itself, but i'd
rather execute a query in access. i...
|
by: Joel |
last post by:
Hello,
ASP does not work locally on my main web site when I
browse the machine locally at the console itself, but to
the outside world all is fine, and ASP executes normally.
I have 4 other...
|
by: Dragonhunter |
last post by:
Hello,
The aspfaq.com seems to really push stored procedures, and I hear the
same advice here all the time. So I want to take the advice.
Is it possible to create and practically maintain,...
|
by: Mats |
last post by:
It's good practice to validate input, not only where it should be coming
from, but from anywhere it's possible to change or add input for a
"client".
If all user input is transfered using "post"...
|
by: Joris Kempen |
last post by:
Hi people,
I know that the question has come around sometimes:
How to open an Access Report using ASP and export it to for example
RTF.
I'm trying to implement the first method of David...
|
by: Mattyboy |
last post by:
Guys
I have built a database with saved queries that runs fine in Access
but when I call it from the web using ASP, an exception occurs. I
have tried multiple ways of testing the databases with...
|
by: InnoCreate |
last post by:
Hi everyone.
I've recently written a classic asp website which uses an MS Access
datasource. I know this is less than an ideal data source as it has
limited functionality. I have a search form on...
|
by: Roland Hall |
last post by:
In Access you use "*" + + "*", + can be replaced with &
Calling a parameterized query in Access requires % be used in place of *,
however, all that I have read show dynamic SQL passed to Access:
...
|
by: shamirza |
last post by:
· What is view state and use of it?
The current property settings of an ASP.NET page and those of any
ASP.NET server controls contained within the page. ASP.NET can detect
when a form is requested...
|
by: k-man |
last post by:
Hi:
I have an MS Access query for a table called MyTable. One of my
fields in the query is a custom field that looks like "MyField: =
MyFunction(ID)" where ID is a field in MyTable.
I have...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |