Fix spelling in title('and' is now 'AND') (#29590)

Changed formatting to add whitespace before and after images, for readability
This commit is contained in:
Vembar Varun
2019-01-19 00:01:36 +00:00
committed by Tom
parent 2f596c93f6
commit 6de321df64

View File

@ -1,9 +1,9 @@
--- ---
title: SQL and Operator title: SQL AND Operator
--- ---
## SQL AND operator
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. ## SQL AND operator
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.
We'll use the student table to present examples. We'll use the student table to present examples.
@ -11,23 +11,27 @@ Here's the student table without a WHERE clause:
```sql ```sql
select * from student; select * from student;
``` ```
![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator01.JPG?raw=true) ![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator01.JPG?raw=true)
Now the WHERE clause is added to display only programming students: Now the WHERE clause is added to display only programming students:
```sql ```sql
select * from student select * from student
where programOfStudy = 'Programming'; where programOfStudy = 'Programming';
``` ```
![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator02.JPG?raw=true) ![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator02.JPG?raw=true)
Now the WHERE clause is updated with AND to show results for programming students that also have a SAT score greater than 800: Now the WHERE clause is updated with AND to show results for programming students that also have a SAT score greater than 800:
```sql ```sql
select * from student select * from student
where programOfStudy = 'Programming' where programOfStudy = 'Programming'
and sat_score > 800; and sat_score > 800;
``` ```
![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator03.JPG?raw=true)
![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator03.JPG?raw=true)
This is a more complex example from the campaign contributions table. This example has a GROUP BY clause with a HAVING clause using an AND to restrict the returned records to candidates from 2016 with contributions between $3 Million and $18 Million in total. This is a more complex example from the campaign contributions table. This example has a GROUP BY clause with a HAVING clause using an AND to restrict the returned records to candidates from 2016 with contributions between $3 Million and $18 Million in total.
```sql ```sql
@ -37,5 +41,6 @@ group by Candidate, Office_Sought, Election_Year
having Election_Year = 2016 and sum(Total_$) between 3000000 and 18000000 having Election_Year = 2016 and sum(Total_$) between 3000000 and 18000000
order by sum(Total_$) desc; order by sum(Total_$) desc;
``` ```
![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator06.JPG?raw=true) ![image-1](https://github.com/SteveChevalier/guide-images/blob/master/and_operator06.JPG?raw=true)