答案 0 :(得分:0)
为什么不尝试一下,sql是如此简单
SELECT * FROM teacher WHERE salary <
(SELECT salary FROM teachear WHERE name='Katherine')
OR
SELECT t1.* FROM teacher t1
JOIN teacher t2 ON t1.salary < t2.salary AND t2.name='atherine'
更新的答案。
通常名称和总数不能在同一级别显示,如果要执行此操作,可以使用GROUP_CONCAT
将所有名称组合为一个记录
SELECT count(t.teacher_id) AS count,GROUP_CONCAT(t.name) as names
FROM teacher t
WHERE t.teacher_id IN
(
SELECT t1.teacher_id FROM teacher t1
JOIN teacher t2 ON t1.salary < t2.salary AND t2.name='atherine'
)