In MySQL, how does one achieve the intersection of query result sets? Through admission batches, layers, course names, Major, and general subjects, the correspondence between the teaching courses and general subjects is set, you can select multiple majors to correspond to the teaching and examination courses. Www.2cto.com: cascade --- influence level of the admission batch. The entry batch and level affect the Major, the entry batch level, and the name of the affected course. When multiple majors are selected, how does the course name drop-down box show the courses that are shared by multiple majors (if you cannot guarantee that the courses are shared, you may add some courses that are not shared by the major. Solution, the query parameter settings are omitted. Solution 1: temporary table: String queryBasic = "select model from"; StringBuilder queryString = new StringBuilder (); queryString. append (queryBasic); For (int I = 0; I <specialIds. length (); I ++) {queryString. append ("(select model from TeachingPlan_CourseDetail model where model. grade =: grade and model. educationLevel and model. specialId =: specialId) a "); queryString. append (I + ""); if (I <specialId. length ()-1) {queryString. append (", ") ;}} If (specialIds. length> 1) {queryString. append ("where a"); queryString. append (1 + ""); queryString. append (". specialId "if (I <specialId. length ()-1) {queryString. append ("=") ;}} solution 2. Intersection joinString queryBasic = "select model from"; StringBuilder queryString = new StringBuilder (); queryString. append (queryBasic); For (int I = 0; I <specialIds. length (); I ++) {queryString. append ("(select model from TeachingPlan_CourseDe Tail model where model. grade =: grade and model. educationLevel and model. specialId =: specialId) as a "); queryString. append (I + ""); if (I <specialId. length ()-1) {queryString. append ("cross") ;}} If (specialIds. length> 1) {For (int I = 0; I <specialIds. length (); I ++) {queryString. append ("a" + I); queryString. append (". specialId "); if (I <specialId. length ()-1) {queryString. append ("=") ;}} solution 3. subqueries are similar to the preceding one, slightly.