Even and odd numbers

razorking

Registered User.
Local time
Today, 15:30
Joined
Aug 27, 2004
Messages
332
Not sure if this is easy or not, I have searched the forum but am not finding what I am looking for. I need to see if there is a way, in a query to extract data specific to either even or odd numbers. So if I have a field on a table with data like this:
A01A
A02A
A03A
A04A
A05A
A06A


I want to pull just the even or odd numbered values.

Any ideas??
 
Where mid(MyField,3,1) in (0,2,4,6,8) ' for even
Where mid(MyField,3,1) in (1,3,5,7,9) ' for odd
 
FoFa,
What would A16A be?

RazorKing,
You need to extract the numeric part of the field. Then mod by 2. 0 = even. anything else = odd.

BTW - it is really poor practice to store multiple attributes in a single field as well as violating first normal form.
 
Pat,

Thanks for the reply, I appreciate it.

The field values are location code definitions for a racking system in a warehouse. I have the location codes stored in a table and am now trying to print location labels that I have made in Acces (also using an activeX control for a barcode). I set up my warehouse location address scheme like a street address (even numbered on one side of an aisle and odd numbered on the other side). Now I would like to print just the lables for one side of the aisle at a time (for ease in labeling the racks).

The first digit of the location defines the aisle.
the second and third digits define the column (as in vertical storage)
the fourth digit defines the shelf in the column.

Pat,

Do I understand your last sentence to mean that I should have three seperate tables setup with the necessary values?

Thanks!
 
You need THREE columns to properly hold this data. Your design currently violates first normal form which states that each attribute must be "atomic". Atomic meaning, not further divisible. You have three attributes -aisle, column, shelf - they each deserve their own column.

Select ....
From ...
Where column mod 2 = 0;

or

Select ....
From ...
Where column mod 2 <> 0;
 
Pat Hartman said:
FoFa,
What would A16A be?
even, the only number that matters is the ones digit.
Don't make it harder than it needs to be.
 

Users who are viewing this thread

Back
Top Bottom