SQL中使用括号处理and和or

更新时间:2023-07-28 10:11:36 阅读: 评论:0

SQL中使⽤括号处理and和or
清廉的古诗>有缘来相会
SQLZOO练习–The JOIN operation
咸水鸭的做法
8.The example query shows all goals scored in the Germany-Greece quarterfinal.
Instead show the name of all players who scored a goal against Germany.
HINT
Select goals scored only by non-German players in matches where GER was the id of either team1 or team2.
You can u teamid!=‘GER’ to prevent listing German players.
You can u DISTINCT to stop players being listed twice.
SELECT distinct player
FROM game inner JOIN goal ON id = matchid
WHERE team1 ='GER'OR team2 ='GER'and teamid !='GER'
赫赫有名的近义词运算结果:
player
Dimitris Salpingidis
Georgios Samaras
Marco Reus
Mario Balotelli
Mario Gómez
Mesut Özil
Michael Krohn-Dehli
Miroslav Klo
Philipp Lahm
领结的打法Robin van Persie
Sami Khedira
正确答案:
秋之梦
SELECT distinct player
FROM game inner JOIN goal ON id = matchid
WHERE(team1 ='GER'OR team2 ='GER')and teamid !='GER'锄禾作者
player
Dimitris Salpingidis
查询个人社保缴费明细Georgios Samaras
Mario Balotelli
Michael Krohn-Dehli
Robin van Persie
由于AND的运算符优先于OR运算符,导致程序先运⾏了 team2 = ‘GER’ and teamid != ‘GER’,然后运⾏了 eam1 = ‘GER’ 。要想优先执⾏OR运算符,得使⽤括号()将OR运算符及两侧的查询条件括起来。
AND运算符的优先级⾼于OR运算符。想要优先执⾏OR运算符时,需要使⽤括号。

本文发布于:2023-07-28 10:11:36,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1099823.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:运算符   查询   运算
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图