Javatpoint Logo
Javatpoint Logo

Where condition in SQL

The MySQL WHERE statement is used to define a circumstance when the data is collected from a separate list or joined to several tables. If the specified circumstance is met, then only the unique value of the table is returned. To extract the information and retrieve only the correct records, you can use the WHERE statement.

Not only, the WHERE condition used in the Selection statement, but it is also used in the UPDATE assertion, DELETE assertion, etc.

Syntax

Now, we have discussed the syntax of the SELECT statement associated with the WHERE condition. It is shown below-

Note: The WHERE condition is used not only in the Selection assertion but also in the UPDATE assertion, the Remove assertion, etc.!

You may use contrast or logical operators, such as >, <, =, LIKE, NOT, etc. To define a state. The below-given example will explicitly state this notation.

For Example-

Here, we consider the table of CUSTOMERS with the below-given records.

CustomerID CustomerName Address Age Salary
001 Hardy Thompson Maxico 25 10000.00
002 Sturt Broad Los Angeles 28 25000.00
003 Joseph Winget California 30 56000.00
004 David Anderson Norway 24 76000.00
005 Alexa Denmark 35 23000.00

Now, we will run the below-given query on SQL to fetch the CustomerID, CustomerName and Salary from the above table CUSTOMERS, where the salary is greater than 25000.

Output

After the successful execution of the above SQL query, we got the following output.

Where condition in SQL

Here, we have another instance where we would get the CustomerID, CustomerName and Salary from the database table named CUSTOMERS for a specific customer named Joseph Winget.

Output

After the successful execution of the above SQL query, we got the above-given outcome.

Where condition in SQL

Note- Here, it should be noted that all strings should be specified within single quotes (''). So, as in the instance discussed earlier, should provide numerical data without any quotation.


Next TopicSQL Injection




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA