简体   繁体   中英

SQL - Command to find rows from two columns of different tables with same D.O.B

I am trying to select those faculty rows which have the same month of birth as that of students, but this code doesn't seem to work. "SQL Error: ORA-00904: "MONTH": invalid identifier" is the error being displayed.

SELECT STUDENT.FIRSTNAME, STUDENT.DOB, FACULTY.FIRSTNAME, FACULTY.DOB
FROM STUDENT, FACULTY
HAVING MONTH(STUDENT.DOB) = MONTH(FACULTY.DOB);

You can Try this:

SELECT STUDENT.FIRSTNAME, STUDENT.DOB, FACULTY.FIRSTNAME, FACULTY.DOB
FROM STUDENT, FACULTY 
where
extract(month from STUDENT.DOB)=extract(month from FACULTY.DOB)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM