e.hadid e.hadid - 1 year ago 94
MySQL Question

how to get Intersection of two query in mysql

I have a table that has two column with two foreign key from two different table.

this is my relation table:


I want to select those student who can speak both language with id 3 and 4.

How can i wrote a query to give me for e.x 12 , 14

Answer Source

Assume you relation is named "myRelation":

SELECT r1.student_Id FROM myRelation r1 join myRelation r2 on r1.student_id = r2.student_id where r1.language_Id = '3' and r2.language_id = '4'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download