sorry for the question, I'm usually using PostgreSQL but MySQL I can't find my legs In it, I have this DB :
create table Students (
Student_id int,
Student_name varchar(100)
);
create table Grades
(
student_id numeric,
Profession varchar(10),
Grade numeric
);
insert into Students(Student_id,Student_name) values (1,"avi"),(2,"david"), (3,"mosh"), (4,"adir");
insert into Grades values (2,'math',95), (3,"sport",25), (4,"english",30);
insert into Grades(student_id,Profession) values (1,'math');
I want to get the student name the other profession paper more than once in this example the output will be:
avi
david
because there both learning math
this is my attempt so far:
select
student_name,
profession
from Students
inner join Grades
on Students.Student_id = Grades.Student_id
group by profession
count(profession) > 1;
this is a link to SQL fiddle