I am having trouble returning the correct records. My database structure is as follows:
TABLE1
ID
TABLE2
MEMBER_ID
START_YEAR
END_YEAR
START_YEAR and END_YEAR are stored in TABLE2 as a number, not an actual year.
Two numbers are static 36 and 55. I need to select any records that have a START_YEAR and END_YEAR range between 36 and 55.
Here is my current query but it only returns records with START_YEAR or END_YEAR values between 36 and 55. I would like to return any record that has a value between its START_YEAR and END_YEAR that falls between 36 and 55.
SELECT COUNT(ID) FROM TABLE1
INNER JOIN TABLE2 ON (MEMBER_ID = ID)
WHERE START_YEAR BETWEEN '36 AND '55' OR
END_YEAR BETWEEN '36' AND '55;
The following would not be returned in this quey but needs to be.
START_YEAR = 22
END_YEAR = 56
I hope this makes since. Thank you for any help!
TABLE1
ID
TABLE2
MEMBER_ID
START_YEAR
END_YEAR
START_YEAR and END_YEAR are stored in TABLE2 as a number, not an actual year.
Two numbers are static 36 and 55. I need to select any records that have a START_YEAR and END_YEAR range between 36 and 55.
Here is my current query but it only returns records with START_YEAR or END_YEAR values between 36 and 55. I would like to return any record that has a value between its START_YEAR and END_YEAR that falls between 36 and 55.
SELECT COUNT(ID) FROM TABLE1
INNER JOIN TABLE2 ON (MEMBER_ID = ID)
WHERE START_YEAR BETWEEN '36 AND '55' OR
END_YEAR BETWEEN '36' AND '55;
The following would not be returned in this quey but needs to be.
START_YEAR = 22
END_YEAR = 56
I hope this makes since. Thank you for any help!