Skip to main content
Known Participant
September 4, 2008
Question

SQL Syntax Question

  • September 4, 2008
  • 1 reply
  • 364 views
I am using CF 7.0 and SQL Server 2003. I'm writing a slightly complex (to me, anyway) SQL query, but I'm not getting the results I want... so I think there's something wrong with my query.

What I want to do is return a list of people from an organization where the date field for the date someone took a course is either earlier than today or NULL.

This is my code so far:

<cfset todayDate = Now()>

Select * FROM qry_memberCourses
WHERE course_id = 30
AND unit_cd = 'CF'
AND (due_dt < #todayDate# OR due_dt = NULL)

the query works, but only returns those records where someone's due date has passed... not those who have a NULL value in the due_dt field. Suggestions?
This topic has been closed for replies.

1 reply

Participating Frequently
September 4, 2008
Try IS NULL

Select * FROM qry_memberCourses
WHERE course_id = 30
AND unit_cd = 'CF'
AND (due_dt < #todayDate# OR due_dt IS NULL)

Phil