Stuck in a Cartesian logic blob

# Thread: Stuck in a Cartesian logic blob

1. Senior Member
Join Date
Dec 1969
Posts
194

## Stuck in a Cartesian logic blob

I have 150 records with 6 fields containing a number 1-5,<BR><BR>I&#039;m trying to select any record where field 1 exceeds the number 2, field 2 exceeds the number 2, field three exceeds 4, etc.<BR><BR>What I&#039;m getting is the 276 records in the name table times the 150 records in the skill table.<BR><BR>This is my statement.<BR><BR>strSKILLS = "SELECT Fname, Lname, SID, Skill1, "<BR> strSKILLS = strSKILLS & "skill2, skill3, slill4, skill5, skill6 "<BR> strSKILLS = strSKILLS & "FROM names, skills "<BR> strSKILLS = strSKILLS & "WHERE names.ID = skills.SID "<BR> strSKILLS = strSKILLS & "AND skill1 &#062; 2 "<BR> strSKILLS = strSKILLS & "OR skill2 &#062; 2 "<BR> strSKILLS = strSKILLS & "OR skill3 &#062; 2 "<BR> strSKILLS = strSKILLS & "OR skill4 &#062; 2 "<BR> strSKILLS = strSKILLS & "OR skill5 &#062; 2 "<BR> strSKILLS = strSKILLS & "OR skill6 &#062; 2 "<BR> strSKILLS = strSKILLS & "ORDER BY skill1 ASC"<BR><BR>Kind of wordy, Any help would be appreciated.<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
2,930

## AND or OR???

maybe, parentheses? AND (skill1 &#062; 2 or skill2 &#062; 2 or skill3 &#062; 2 etc...)<BR><BR>or do all AND&#039;s like AND skill1 &#062; 2 AND skill2 &#062; 2 AND ... AND skill6 &#062; 2... i don&#039;t know your logic, so this is the only help i can offer...

3. Senior Member
Join Date
Dec 1969
Posts
2,930

## Tip

Whenever you have a logic problem, just go through in your head... <BR><BR>"I want to select all the records where one of these skill levels is greater than 2"<BR><BR>=<BR><BR>AND (skill1 &#062; 2 OR skill2 &#062; 2 OR skill3 &#062; 2 etc...)<BR><BR>...<BR><BR>"I want to select all records where all the skill levels are greater than 2"<BR><BR>=<BR><BR>AND skill1 &#062; 2 AND skill2 &#062; 2 AND skill3 &#062; 2 AND ... etc...<BR><BR>hope that helps you now and in the future.

4. Senior Member
Join Date
Dec 1969
Posts
194

## RE: Tip

I knew what I wanted.(the first example)<BR><BR>The ( ) is what did it. Thanks!

5. Senior Member
Join Date
Dec 1969
Posts
2,930

## oh...

sorry... also, you&#039;re selecting From names and skills...<BR>so add this <BR><BR>strSKILLS = "SELECT Names.Fname, Names.Lname, Names.SID, Names.Skill1, "<BR>strSKILLS = strSKILLS & "Names.skill2, Names.skill3, Names.slill4, Names.skill5, Names.skill6 "<BR><BR>that might help... sorry i didn&#039;t see that before.<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•