设为首页 加入收藏

TOP

Hive中and和or的执行顺序
2018-11-29 02:03:04 】 浏览:45
Tags:Hive and 执行 顺序
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39468795/article/details/78346873

今天在网上看到hive中and的执行优先级比or高,觉得很奇怪,于是就亲自尝试了一下,发现果然如此,下面是我测试的一些简单语句:

select 1 from student where 1=0 or 1=1 and 1 = 0;

执行结果为空

select 1 from student where 1=0 or 1=1 and 1 =1;

执行结果为1

第二个select语句毫无疑问where语句后面的值返回为true,无论and或者or的优先级如何都一样,但是第一个select语句缺不是从左到右执行的,相当于select 1 from student where 1 = 0 or (1=1 and 1 = 0);


在此问一个问题,where语句后面可以跟两个in (子查询)吗 ? 如select name from student where name in (select nam from student) and name in (select name from student);

我试过这样写,但却是错误的,错误如下:


这样的写法有什么问题?如何才是正确的写法?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇常用的hive sql函数总结 下一篇HiveSql语句(1)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目