Oracle SQL where语句的问题

时间:2018-05-09 14:35:10

标签: sql database oracle

大家好,我是SQL新手,在执行简单的select命令时遇到以下问题。以下是代码:

SQL:

select cheffname
from speciality
where speciality = 'Japanese Cuisine';

输出:

Daniel
Pamela
Sarah

SQL:

select cheffname
from speciality
where speciality = 'Chinese Cuisine';

输出:

Daniel
Jerry

SQL

select cheffname
from speciality
where speciality = 'Chinese Cuisine' and speciality = 'Japanese Cuisine';

输出:

no rows selected 

正如您所看到的,我希望第三个SQL查询返回Daniel,但事实并非如此。我做错了什么?

3 个答案:

答案 0 :(得分:1)

我相信你想要:

login_path: app_security_login
check_path: app_security_login

答案 1 :(得分:0)

INTERSECT是一种选择。

SELECT cheffname
FROM speciality
WHERE speciality = 'Chinese Cuisine'
 INTERSECT
SELECT cheffname
FROM speciality
WHERE speciality = 'Japanese Cuisine'

答案 2 :(得分:0)

你没有选择任何行'因为这个查询,

select cheffname from speciality where speciality = 'Chinese Cuisine' and speciality = 'Japanese Cuisine';
当where子句中的两个条件都为真时,

返回行,在你的情况下,它永远不可能,因为你在同一列特殊性上写了2个条件。我希望你理解它,并且你可以通过几种方式获得所需的输出,其中一个是,< / p>

select cheffname from speciality where speciality = 'Chinese Cuisine'
union
select cheffname from speciality where speciality = 'Japanese Cuisine'