mysql - SQL query not returning any data -
so i'm having issue trying return records have 2 conditions not equal.
i have 3 tables: person, student, , instructor. i'm trying return list of persons neither students or instructors.
here tables (they populated values fit criteria):
create table person ( name char (20), id char (9) not null, address char (30), dob date, primary key (id) ); create table instructor ( instructorid char (9) not null references person (id), rank char (12), salary integer, primary key (instructorid) ); create table student ( studentid char (9) not null references person (id), classification char (10), gpa double, mentorid char (9) references instructor (instructorid), credithours integer, primary key (studentid) );
and here answer/query:
select person.id, person.name, person.dob person right join student on person.id = student.studentid right join instructor on person.id = instructor.instructorid not person.id = student.studentid , person.id = instructor.instructorid;
did screw on joins? i'm not getting errors, query isn't returning either. i've tried joins (left, right, full) no avail.
any appreciated.
you may use not in determine if records not in both of tables
select id, name, dob person id not in (select studentid student) , id not in (select instructorid instructor);
Comments
Post a Comment