sql运算符_SQL AND运算符解释语法示例

sql运算符

AND is used in a WHERE clause or a GROUP BY HAVING clause to limit the rows returned from the executed statement. Use AND when it’s required to have more than one condition met.

在WHERE子句或GROUP BY HAVING子句中使用AND来限制从已执行语句返回的行。 当需要满足多个条件时,请使用AND。

We’ll use the student table to present examples.

我们将使用学生表展示示例。

Here’s the student table without a WHERE clause:

这是不带WHERE子句的学生表:

select * from student;

Now the WHERE clause is added to display only programming students:

现在,添加了WHERE子句以仅显示编程学生:

select * from student 
where programOfStudy = 'Programming';

Now the WHERE clause is updated with AND to show results for programming students that also have a SAT score greater than 800:

现在,WHERE子句使用AND更新,以显示对SAT分数也大于800的编程学生的结果:

select * from student 
where programOfStudy = 'Programming' 
and sat_score > 800;

This is a more complex example from the campaign contributions table. This example has a GROUP BY clause with HAVING clause using an AND to restrict the returned records to candidates from 2016 with contributions between $3 Million and $18 Million in total.

这是广告系列贡献表中更复杂的示例。 此示例具有GROUP BY子句和HAVING子句,并使用AND来将返回的记录限制为2016年以来的候选者,贡献总额在300万美元至1800万美元之间。

select Candidate, Office_Sought, Election_Year, FORMAT(sum(Total_$),2) from combined_party_data
where Office_Sought = 'PRESIDENT / VICE PRESIDENT'
group by Candidate, Office_Sought, Election_Year
 having Election_Year = 2016 and sum(Total_$) between 3000000 and 18000000
order by sum(Total_$) desc;

翻译自: https://www.freecodecamp.org/news/the-sql-and-operator-explained-examples/

sql运算符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值