如何获取具有条件的mysql查询结果

teacher table

teacher_id      teacher_name
============================
1               john
2               doe

student table

student_id      student_name    student_score   teacher_id
==========================================================
1               amelia          0               1
2               anderson        0               1
3               fabiano         0               1
4               ronaldo         0               2
5               peter           6               2
6               alex            0               2

result

teacher_id      teacher_name
============================
2               doe

the result is teacher record who one or more of his student score > 0.

How the query of this ?

thanks for the answer and sorry for my bad english

A simple subquery does the trick

SELECT * FROM teacher WHERE teacher_id IN
(SELECT teacher_id FROM student WHERE student_score > 0)

Also possible is an INNER JOIN

SELECT teacher.* FROM teacher
LEFT JOIN student as student teacher.teacher_id = student.teacher_id
WHERE student.student_score > 0

Hopefully this will works for you.