Community
Showing results for 
Search instead for 
Do you mean 
Reply

Advanced Query Problem

cj
New Member
Posts: 1
Country: United States

Advanced Query Problem

I am building a query to lookup for the following :

 

Last User, Date and Comment.

 

My formula is as follows...

 

Field:         Operator:      Value:

Last User        =              "Me"

Date              =             "today"

Comment        =              "call"

 

Using AND displays none, using just one OR will show all including all Dates all Last users and All Comments.

 

I tried using parenthesis but still no good.

Anyone who can help?

 

 

Copper Contributor
Posts: 36
Country: United States

Re: Advanced Query Problem

[ Edited ]

First of all, I personally would never mix AND and OR operators without using ()'s.

 

Although computers have rules for this kind of thing and NEVER get confused, most people I know have a heck of a time figuring it out.

 

If I write:

A AND B OR C

 

Was that:

(A AND B) OR C

 

Or was it:

A AND (B OR C)

 

The two queries are very different.

 

You probably know this, but a reminder probably wouldn't hurt:

AND means that the expression is true only if both items on either side of the AND are true.

OR means that the expression is true if either item on either side of the OR is true.

 

 

If you want to figure out what is going on, there is a simple way to do this:

 

Go to the list view, and show the three columns in this order:

Last User, Date, Comment

 

Next, set your Advanced Query to:

Last User = "Me"

 

Look at the results.  You should see only "Me" in the Last User column.

Look at the Date field (sort by Date is easiest...)  Try to find anything with todays date.

 

Next, set your Advanced Query to:

Last User = "Me"

Date = "today"

 

Look at the results.  You should know what rows you expect to see from earlier.  If you are missing any rows that you expected, then try to figure out why.

 

If you see all the rows you expected, look at the Comment column.  Find any rows where Comment = "call".

 

Next, set your Advanced Query to:

Last User = "Me"

Date = "today"

Comment = "call"

 

You should now only see the rows you noted last time.

 

 

 

 

Some general comments:

Date = "today"

 

In many systems, dates are stored as date/time values.  This means that if you are looking for items that were edited "today", you actually should not be looking for date = "today", but instead should be looking for:

 

(Date >= "today" AND Date < "tomorrow" )

 

This will get you anything where the date is in the 24 hour period of today.  If you only do wher Date = "today", you will only get you things which happened exactly at midnight.

 

Comment = "call"

I do not know what you are putting into your Comment field.  It may be better for your query to change this to one of the following:

 

Comment "Ccontains" call

Comment "Starts With" call

 

Using "Equals" will only match if the entire Comment field is "call", and nothing else, so the following Comments would not be found:

 

Call RealNobody and tell him his posts are awful

Please call RealNobody and tell him to stop posting

I love callendars even though I cannot spell it properly

 

This should help you to figure out what is happening.

Message Edited by RealNobody on 11-19-2008 05:29 AM