SQL AND OR NOT and XOR statement can be used with WHERE clause to list a set of records
with matching combination of a database table.
This is our table ( Showing 10 records ) ,
id
name
class
mark
sex
1
John Deo
Four
78
male
2
Max Ruin
Three
85
male
3
Arnold
Three
55
male
4
Krish Star
Four
60
male
5
John Mike
Four
60
male
6
Alex John
Four
55
male
7
My John Rob
Fifth
78
male
8
Asruid
Five
85
male
9
Tes Qry
Six
78
male
10
Big John
Four
55
male
We will apply AND command to display records of class Four with more
than 70 mark.
Here the records returned are either belongs to class Five OR having mark more than 90. Any one of the two condition is to be satisfied.
AND OR
condition1 OR condition2 Any one of the condition has to be satisfied for the record
condition1 AND condition2 Both conditions are to be satisfied for the record.
Using both AND OR with bracket.
Display all students of class Five and Six who got more than 80 mark.
You have one student with 75 mark .... This is because in our query considers all students of class six who has got more than 80 but does not apply the same condition of mark more than 80 to students of class Five. We used one OR condition in wrong place. Here is the correct SQL
Passionate about coding and teaching, I publish practical tutorials on PHP, Python,
JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and
project‑oriented with real examples and source code.