Query Criteria Question

Cameroncha

Registered User.
Local time
Today, 23:10
Joined
Jul 1, 2002
Messages
58
I have a report that i want to include only a select few titles that have a SportID name "skate" but that only falls within a certain sku range or value.... what would the syntax of this be?

you can see my really bad attemp below:

this is the SportID Criteria field... I dont want all skate titles to show up... only a certain numeric range.

querycriteria----------------------------->>

Like "fght" Or Like "4x4" Or Like "pool" Or Like "street" Or Like "WRESL" or like "skate" (where([Title]![Sku]] like "sk73*"))
 
Assuming SportID and Sku are two fields in the same table, set the criteria as follows:

For the SportID field:-
Criteria: In ("fght","4x4","pool","street","WRESL")
Or:        "skate"

For the Sku field:-
Criteria:
Or:        Like "sk73*"

(as shown in the attached jpg image)


Or you can switch the query to SQL View and directly type the following Where Clause in the SQL statement:

SELECT SportID, Sku
FROM [TableName]
WHERE SportID In ("fght","4x4","pool","street","WRESL") OR (SportID="skate" AND Sku Like "sk73*");
 

Attachments

  • sportid.jpg
    sportid.jpg
    25.1 KB · Views: 174
Last edited:
I understand what you did above... however

the fields aren't from the same table... they are being combined together in a query for a report. I am trying limit a subset of sku values that start with sk... but include all the other records because they are all of the other sports: wb... is wakeboarding, mx... is motocross ect ect. The problem is that i can't use filters for sku because i can't pinpoint the data as clearly as i need, and i can't use sportID for the same reason... so somehow i need to get pieces of each.

I Want to limit those sku values WITHIN sports that are equal to skateboarding.... but if i simply say sku="sk73*" then it excludes all of the other sku's that are associated with the other sports specified in the sportID field.

I will post an example of what i am talking about tomorrow when i am back at work. I am probably not making much sense.

thanks... Cam_
 
actually... looking at what you did again... i see that i did not do things that way before.... i will try as you are showing it.... thanks.


what if they are coming from 2 different tables though.
 
If the two fields are coming from two tables, just add the two tables in query design, drag the linking field from one table to the other, then set the criteria for the two fields.

The basic principle is that criteria in the same row are joined by AND while criteria in different rows are joined by OR.

So the criteria
"skate" (for the SportID field) and Like "sk73*" (for the Sku field)

need to be put in one row.
 
Last edited:
Thanks.... you have been very helpful. I dont know what i would do without this forum (and people like you)
 

Users who are viewing this thread

Back
Top Bottom