Skip to content
  • About Author
  • About UgtWorld
  • Privacy Policy
  • The Era of Techno
  • Write With Us
Ugt world

Ugt world

Flow of Emotion

  • Artificial Intelligence Free Course
  • Google Explore
    • Career Opportunities
    • Travel and Roaming
    • Physical and Mental Health
    • Sci-Fi
  • हिंदी
    • हिंदी लेख
    • हिंदी लघु-लेख
    • हिंदी कथा
    • हिंदी कविताएँ
    • हिंदी शायरी
      • Love Shayari
      • Friendship Shayari
      • Sad-Heartbroken Shayari
      • Motivational Shayari
      • Life Shayari
      • Chai Shayari
      • Khubsurati Shayari
  • मराठी
    • मराठी लेख
    • मराठी लघु-लेख
    • मराठी लघु-लेख : २
    • मराठी कथा
    • मराठी कविता
    • मराठी चारोळ्या
      • चारोळ्या – प्रेम
      • चारोळ्या – पहाट
      • चारोळ्या – रात्र
      • चारोळ्या – आयुष्य
    • मराठी सुविचार
  • English
    • Quotes
      • Inspirational Quotes
      • Motivational Quotes
      • Life Quotes
      • Attitude Quotes
      • Love Quotes
      • Happy Quotes
      • Sad Quotes
    • Blogs
      • Social Awareness
      • Motivational
      • Life Lessons
      • Love
      • Friendship
    • Micro Blogs
    • Micro Blogs 2
    • Story
    • English Poetry
  • Banking and Finance
  • The Era of Techno
    • Social Engineering Attacks
    • Java
      • Introduction of Java, the technological language…
      • Set-up of Java
    • MySQL
    • Spring
  • Fashion Design
  • Write With Us
    • Suhani’s Write-ups
    • Revathi ‘s Write-ups
    • Rachna’s Blog
    • Pooja’s Write-ups
    • Komal’s Write-ups
    • Tanaya Talks
    • AKWrites
    • Rutuja’s Write-ups
    • Samreen ‘s Write-ups
    • शायAr
      • Marathi Blogs
      • Marathi Story
      • Hindi Blogs
      • English Blogs
      • English Stories
  • Home
  • English
  • Blogs
  • MySQL Operators
Blogs Database Era of Techno MySQL

MySQL Operators

November 22, 2022November 22, 2022 ugtworld

What are MySQL operators?

We can use MySQL operators in conditions with more than one condition. Those are AND, OR, NOT.

We will use the same students table we have created in MySQL SELECT Statement.

We will see conditions with example one by one :

AND 

This is used when all the conditions are added in the WHERE should be TRUE.

Syntax: 

SELECT columnName1, columnName2, ...
FROM schema.table_name
WHERE condition1 AND condition2 AND condition3 ...;

As shown in the following example where we want to get the records for M as gender and class greater or less than 3.

Example 1:

select * from students where gender = 'M' AND class >= 3;

Example 2:

select * from students where gender = 'M' AND class >= 3 AND marks > 300;

OR

If we want to get the records for either one condition is TRUE.

Syntax: 

SELECT columnName1, columnName2, ...
FROM schema.table_name
WHERE condition1 OR condition2 OR condition3 ...;

Example 1:

select * from students where gender = 'M' OR class >= 5;

Example 2:

select * from students 
where gender = 'M' OR class >= 5 OR marks > 300;

NOT

If we want to get the details which is not like the mentioned value then we can use NOT operator.

Syntax:

SELECT columnName1, columnName2, ... 
FROM schema.table_name 
WHERE NOT condition

Example 1:

select * from students where NOT gender = 'M';

Example 2:

select * from students where NOT marks > 300;

We can also use the combinations of above operators in where condition to get the records.

Example for AND + OR 

If we want to get the students of gender M and class >=3 or student having name as KMS then we can write following condition.

Note that the bracket is added for AND condition. If we remove/change the bracket we may get the different records set.

select * from students 
where (gender = 'M' AND class >= 3) OR marks < 300;

Now we will just change the bracket’s position to the the records.

select * from students 
where gender = 'M' AND (class >= 3 OR marks < 300);

Example for AND + NOT

select * from students 
where gender = 'M' AND NOT class < 4;

Example for OR + NOT

select * from students 
where gender = 'M' OR NOT class < 4;

Example for AND + OR + NOT

select * from students 
where (gender = 'M' AND NOT class < 4) OR class > 3;

Changing the NOT position:

select * from students 
where (gender = 'M' AND class < 4) OR NOT class > 3;

-A blog by Shwetali Khambe

Click here to read all about MySQL
0Like
0Love
0Haha
0Shocked
0Sad
0Angry

Related Posts

History of fashion part-4
Blogs Career Opportunities English Fashion Design Google Explore

History of fashion part-4

March 9, 2025March 9, 2025 ugtworld
History of fashion part-3 Indian Dynasty, The Mughal fashion
Blogs Career Opportunities English English Blogs Fashion Design

History of fashion part-3

March 7, 2025March 7, 2025 ugtworld

Post navigation

Previous: Revathi ‘s Write-ups
Next: Child Psychology (Part-2)

Aapsi Baatchit aur Kissein / आपसी बातचीत और किस्से

Aapsi Baatchit aur Kissein / आपसी बातचीत और किस्से
Shop now on Notion Press, Amazon and Flipkart

Write With Us

Write with us

AMAZON BANNER

Follow Us

Copyright ©2024 Ugtworld. All rights reserved.
Proudly powered by WordPress | Theme: Fairy by Candid Themes.