Select rows with a date lower than another MySQL

-3

The tables that are available in the exercise are:

Master

master_id |INT ----> PRIMARY KEY
name | VARCHAR ----> ALTERNATIVE KEY
curriculum_rev | DATE

Subject

subject_id | VARCHAR -----> PRIMARY KEY
name | VARCHAR
language | ENUM
description |VARCHAR
ECTS | INT
m_id | INT ----> FOREIGN KEY REFERENCES master_id 

Question: You want to get a MySQL statement showing the name of the master, subjects, credits and language taught but only those that do not have a description and the revision of the curriculum (curriculum_rev) of the Master is prior to 2016.

For this, I have made the following sentence:

select m.name,s.name,s.'language',s.ECTS
from master m, subject s
where m.master_id=s.m_id AND description is null AND m.curriculum_date < 2016

It gives me a syntax error and I suppose it is with the treatment of the date. How can I do it? Thanks.

    
asked by Panri93 27.12.2018 в 19:04
source

1 answer

0

Welcome Panri93. The year () function helps to show only the year of a certain date. With this function you can evaluate with the year 2016.

select  master.name, subject.name, ECTS, language
from    master, subject 
where   master.master_id = subject.m_id and 
        description is null and 
        year(curriculum_rev) < 2016 
    
answered by 27.12.2018 / 19:28
source