我正在尝试创建一个联盟
创建一个工会以提供ID为100且工资低于65,000的教师的结果。
faculty
facID name salary
320 Laura Kassler 50000
125 Charity Burbage 62000
500 Pomona Sprout 61000
100 Minerva McGonagall 85000
185 Severus Snape 70000
200 Rubeus Hagrid 50000
这是我的代码:
select name, facID, salary
from faculty
where salary < '65000'
UNION
select name, facID, salary
from faculty
where facID like '1%';
结果:
+--------------------+-------+--------+
| name | facID | salary |
+--------------------+-------+--------+
| Minerva McGonagall | 100 | 85000 |
| Charity Burbage | 125 | 62000 |
| Severus Snape | 185 | 70000 |
| Rubeus Hagrid | 200 | 50000 |
| Laura Kassler | 320 | 50000 |
| Pomona Sprout | 500 | 61000 |
+--------------------+-------+--------+
答案应该是Charb Burfage facID 125,工资为62000。
我究竟做错了什么?
最佳答案
select name, facID, salary
from faculty
where salary < '65000'
and facID like '1%'
order by facID;
关于mysql - MySQL UNION,带有Like和<,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40898578/