我的目标是 Select 没有老板或他们的老板住在含有字母‘o’或字母‘u’的街道上的员工的全名.然后,我想按全名降序列出它们. 问题出在排序上,因为通过我认为相同的查询,我得到了不同的答案.
当我在MySQL工作台中引入以下命令时:
select concat(surnames,', ',name) as 'Full Name', street
from employee
where boss is null or (boss is not null and (street like'%u%' or steet like '%o%'))
order by concat(surnames,', ',name) desc;
通过这个命令,我得到了我想要的答案,即:
Full Name Street
Suárez García, Juan Juan Valdés 25
Sarasola Goñi, Vanesa Austria
Requena Santos, Pilar Alicante 3
Puertas Elorza, Marta Lope de Vega 3
Piedra Trujillo, Ramón Madre Vedruna 21
Narváez Alonso, Alba Vara de Rey 22
Gómez de la Sierra, Francisco Loscertales 9
Chávarri Díez, Lorea
Arrieta Alcorta, Kepa Urbieta 33
Álvarez González, Ana Graus 19
但当我更改另一个在我看来相同的顺序时:
select concat(surnames,', ',name) as 'Full Name', street
from employee
where boss is null or (boss is not null and (street like'%u%' or steet like '%o%'))
order by 'FullName' desc;
我得到了一个错误的答案,如下所示:
Full Name Street
Suárez García, Juan Juan Valdés 25
Puertas Elorza, Marta Lope de Vega 3
Chávarri Díez, Lorea
Narváez Alonso, Alba Vara de Rey 22
Gómez de la Sierra, Francisco Loscertales 9
Piedra Trujillo, Ramón Madre Vedruna 21
Sarasola Goñi, Vanesa Austria
Requena Santos, Pilar Alicante 3
Álvarez González, Ana Graus 19
Arrieta Alcorta, Kepa Urbieta 33
有人能告诉我这是怎么回事吗?