MySQL: WHERE Clause

Profile picture for user arilio666

When we wanna filter out specific data out of a table and need the specific stuff out of a specific date WHERE clause is the stuff you need.

The WHERE clause filters data out of the specific table with the help of some comparison operators such as >, >=, <, <=, =, != or <>

So let us dive into how the where clause works in this article we will be doing operations paired up with the SELECT statement.

Syntax

SELECT * from table_name WHERE column_name (comparison operator) value;

So let us take a real-time example where we will do a simple operation on how we can fetch filtered data based upon the needed requirement.

Here is what we will do:

  - We will use the SELECT statement to fetch the required columns and filter out the orders made in the present year.
  
For demo purposes, we will be using this orders table.

From this, we will be fetching orders made in the year 2019 alone.

Example:

select * from orders where order_date >= '2019-01-01';

So we have used the SELECT statement as we discussed and fetched the total table details and in that, we use the WHERE clause to filter out the orders made/happened in the year of 2019 alone for that we have used the comparison operator >=.

Tags