If you were wondering how to use the WHERE operator in MYSQL, then you got where you need to. Many newcomers do not understand why it is needed, and when it can be used. This is a very useful skill that will greatly help you in the future use of queries.
Definition
Where is used as a filter for results in SELECT, UPDATE, INSERT, DELETE.
That is, he chooses the information that will perform certain actions.
Next you can see the syntax:
WHERE conditions;
Conditions - conditions.
Examples
Let's look at some examples using this operator.
Where MYSQL has several values, and they can be used in different situations.
For example, we have a table with users. We need to remove the user by name.
SELECT * FROM users
In this example, we clearly saw that the AND condition is used, which means that WHERE is used to combine the two conditions.
The OR condition is written in the same way:
SELECT * FROM users
This operator, as already clear, returns a result with the name Ivan or the name Maximov.
Also, the last two operators can be combined to make it not so difficult. We execute the code below:
SELECT * FROM users
As we can see, we have two conditions combined - OR and AND.
This means that as a result, users with the name Ivan and Surname Maximov will be displayed, as well as users with the middle name Alexandrov.
There are many where values, and you can use them both important and very practical.
Conclusion
WHERE is one of the most important in the structured query language and is found in almost all projects. It also has AND and OR operators that combine several conditions into one query, which helps a lot not to rewrite the same query several times and perform complex and interesting tasks.
In this article we talked in detail about its several meanings and stepped a little ahead in the study of programming languages, now it’s one step closer to becoming a true web programmer, and if you try the same as you tried before, then everything will work out, and you will become whom they dreamed of.