Home > database >  Mysql query
Mysql query

Time:09-17

Recent database principle of network course at home, this feeling is not very good, please leaders solve my confused situation of the third (see the first two right)
Thank you very much

CodePudding user response:

Try:
Select distinct s. student id, name, gender, the from student_info s
Left the join grade g on s. student id=g, g student id and course number in (' 0002 ', '0005')

CodePudding user response:

Upstairs positive solution, SQL join must be used

CodePudding user response:

reference 1st floor dragoyes response:
try:
Select distinct s. student id, name, gender, the from student_info s
Left the join grade g on s. student id=g, g student id and course number in (' 0002 ', '0005')




This is found as a result, my only student number is 0006 and 0007 in the database to learn the course of 0002 and 0005,
This left connection will conform to the join condition and student information other are displayed in the table,
If does not conform to the requirements, it should be a little problem

CodePudding user response:

Select distinct s. student id, name, gender, the from student_info s
Left the join grade g on s. student id=g. student id
Where g. course number in (' 0002 ', '0005')

Write the where condition that will filter out do not conform to the condition of the student
If behind the left join on limiting conditions, is not in conformity with the displays of null, select here only s. student id, name, gender, if combined with courses Numbers should be empty

CodePudding user response:

Fang Ling reference 4 floor is a little lovely reply:
select distinct s. student id, name, gender, the from student_info s
Left the join grade g on s. student id=g. student id
Where g. course number in (' 0002 ', '0005')

Write the where condition that will filter out do not conform to the condition of the student
If behind the left join on limiting conditions, is not in conformity with the displays of null, select here only s. student id, name, gender, if combined with courses Numbers should be empty



The above query with me in the first case is the same, 0002 and 0005 courses as long as one will be found out,

CodePudding user response:

reference 5 floor when the wind back 0.0 response:
Quote: Fang Ling reference 4 floor is a little lovely reply:

Select distinct s. student id, name, gender, the from student_info s
Left the join grade g on s. student id=g. student id
Where g. course number in (' 0002 ', '0005')

Write the where condition that will filter out do not conform to the condition of the student
If behind the left join on limiting conditions, is not in conformity with the displays of null, select here only s. student id, name, gender, if combined with courses Numbers should be empty



The above query with me in the first case is the same, 0002 and 0005 courses as long as one will be found out,


Select *
The from
(select student number, course number 1 from grade
Where course id='0002') as a
Inner join
(select student number, course number 2 from grade
Where course id='0005') as b
Student id=on a. b. student id

This mean?

CodePudding user response:

Select *
The from
(select student number, course number from grade
Where course id='0002') as a
Inner join
(select student number, course number from grade
Where course id='0005') as b
Student id=on a. b. student id

CodePudding user response:

Fang Ling reference 7 floor is a little lovely reply:
select *
The from
(select student number, course number from grade
Where course id='0002') as a
Inner join
(select student number, course number from grade
Where course id='0005') as b
Student id=on a. b. student id



As if is not this meaning, and, in fact is the learners in 0002 or 0005, a and other courses; Some study of 0002 and 0005 also learned other classes; Then some people just learn the lessons of 0005 and 0002; I want to find out which one the back, and I don't know if I have any say
  • Related