学无先后,达者为师

网站首页 编程语言 正文

sql语句:and与or的优先级

作者:黄佳俊、 更新时间: 2022-02-04 编程语言

and的优先级大于or 我这里写大括号方便区分,表示两个条件或两个条件 可以省略括号
 

select device_id,gender,age,university,gpa from user_profile
where (university='山东大学' and gpa>3.5 )
or (university="复旦大学" and gpa>3.8);

等效于

select device_id,gender,age,university,gpa
from user_profile
where university='山东大学' and gpa>3.5 or university='复旦大学' and gpa>3.8

原文链接:https://blog.csdn.net/weixin_48419914/article/details/122278971

栏目分类
最近更新