Parameter Query and "OR"

S

Student Databaser

I am trying to run a query that will show me the courses in a table that
began during a certain time period AND all on going courses that began before
the designated period. It seems so simple, but for some reason its not
working.

Here's the SQL:

SELECT COURSE_OFFERINGS.COURSE_NAME, COURSE_OFFERINGS.BEGIN_DATE,
COURSE_OFFERINGS.DELIVERY_MODE
FROM COURSE_OFFERINGS
WHERE (((COURSE_OFFERINGS.BEGIN_DATE) Between [start date] And [end date]))
OR (((COURSE_OFFERINGS.DELIVERY_MODE)="ON GOING"));
 
K

Ken Sheridan

Its always a good idea to declare date/time parameters as otherwise they
might be misinterpreted as arithmetical expressions. Try:

PARAMETERS [start date] DATETIME, [end date] DATETIME;
SELECT course_name, begin_date, delivery_mode
FROM course_offerings
WHERE begin_date BETWEEN [start date] AND [end date]
OR delivery_mode = "On Going";

Another possible cause of error is if delivery_mode is a foreign key column
referencing a numeric primary key of another table, e.g. delivery_modes, but
set up to show the text value from the other table. This will be the case if
the dreaded 'lookup wizard' has been used when setting the data type of the
column. If this is the case then the tables should be joined in the query,
and restricted on the value of the text column from the referenced table
being "On Going".

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top