AND,OR,NOT and WHERE Conditions
- AND Condition
SELECT column_name_1, column_name_2 from table_name
WHERE condition_1 AND condition_2
WHERE condition_1 AND condition_2
ID | Name | City |
State |
---|---|---|---|
1 | Raj | Mumbai |
Maharashtra |
2 | Rahul | Nashik |
Maharashtra |
3 | Saurabh | Nagar | Maharashtra |
4 | Ryan | panaji | Goa |
SELECT * from Detail where state='Maharashtra' AND city='Mumbai'
ID | Name | City |
State |
---|---|---|---|
1 | Raj | Mumbai |
Maharashtra |
- OR Condtion
SELECT column_name_1, column_name_2 from table_name
WHERE condition_1 OR condition_2
WHERE condition_1 OR condition_2
ID | Name | City |
State |
---|---|---|---|
1 | Raj | Mumbai |
Maharashtra |
2 | Rahul | Nashik |
Maharashtra |
3 | Saurabh | Nagar | Maharashtra |
4 | Ryan | panaji | Goa |
SELECT * from Detail where state='Maharashtra' OR city='Nashik'
ID Name City State
2 Rahul Mumbai Maharashtra
2 Rahul Mumbai Maharashtra
- NOT condition
WHERE column_name_1, column_name_2 from table_name
WHERE NOT condition
WHERE NOT condition
ID | Name | City |
State |
---|---|---|---|
1 | Raj | Mumbai |
Maharashtra |
2 | Rahul | Nashik |
Maharashtra |
3 | Saurabh | Nagar | Maharashtra |
4 | Ryan | panaji | Goa |
SELECT * from Detail where not State='Maharashtra'
ID | Name | City |
State |
---|---|---|---|
4 | Ryan | panaji | Goa |
SELECT column_name_1,column_name_2 from table_name
WHERE condition;
WHERE condition;
ID | Name |
City |
---|---|---|
1 | Raj |
Mumbai |
2 | Rahul |
Nashik |
3 | Saurabh | Nagar |
ID | Name |
City |
---|---|---|
1 | Raj |
Mumbai |
ID | Name |
City |
---|---|---|
2 | Rahul
|
Nashik |
AND,OR,NOT and WHERE Conditions
Reviewed by LanguageExpert
on
August 06, 2017
Rating:
Very Nice vishal !!
ReplyDeleteThank you
Delete