SQL PHP HTML ASP JavaScript articles and free scripts to download
SQL

SQL AND OR in WHERE query Commands and statements

SQL AND OR statement can be used with WHERE clause to list a set of  records with matching combination of a table. We can use these logical operators in query with NOT combination also to filter out some records.
This is our table

id name class mark
1 John Deo Four 75
2 Max Ruin Three 85
3 Arnold Three 55
4 Krish Star Four 60
5 John Mike Four 60
6 Alex John Four 55
7 My John Rob Fifth 78
 
We will apply AND  command to display records of class Four with more than 70 mark.

SELECT * FROM student WHERE class='Four' AND mark >70

id name class mark
1 John Deo Four 75
 WE can see the record returned is class= Four and mark is more than 70. Here both the conditions are satisfied. 

SELECT * FROM student WHERE class='Four' OR mark >70

id name class mark
1 John Deo Four 75
2 Max Ruin Three 85
4 Krish Star Four 60
5 John Mike Four 60
6 Alex John Four 55
7 My John Rob Fifth 78
Here the records returned are either belongs to class Four OR having mark more than 70. Any one of the two condition is to be satisfied.

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer