Jump to content

Archived

This topic is now archived and is closed to further replies.

dug

Like operator

Recommended Posts

Hi folks,

is the below query correct? 

retrieve all courses in the past that have a name that starts with Cert


SELECT c.ID AS 'Course ID',
date_format(c.start_date,'%d/%m/%Y') AS 'Start Date',
date_format(c.end_date,'%d/%m/%Y') AS 'End Date' ,
t.description AS 'Course Description',

FROM media_courses AS c
INNER JOIN media_courses_type AS t
ON t.ID = c.media_courses_type_ID

WHERE c.end_date < NOW()
AND t.description LIKE 'Cert%'
ORDER BY c.start_date ASC


Thanks

dug

Share this post


Link to post
Share on other sites
Looks fine to me... but you should have kept this post in the original thread.

Share this post


Link to post
Share on other sites
thanks fenway.  sorry for re-posting.  while you here on the initial post for this question:

Re-write the query to return all courses that are more than 1 day in length

you said i should subtract start and end date, is this what you meant?

SELECT c.ID AS 'Course ID',
date_format(c.start_date,'%d/%m/%Y') AS 'Start Date',
date_format(c.end_date,'%d/%m/%Y') AS 'End Date' ,
t.description AS 'Course Description',

FROM media_courses AS c
INNER JOIN media_courses_type AS t
      ON t.ID = c.media_courses_type_ID

[b]WHERE c.start_date – c.end_date[/b]
ORDER BY c.start_date ASC

Share this post


Link to post
Share on other sites
No... check out the TO_DAYS() function.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.