48 SQL Injection Logical Operators Part 6

כללי / תכנות כללי 39 צפיות 22/09/2022
פתח ב-YouTube

דרג סרטון זה

התחבר כדי לדרג

תיאור

SQL Logical Operators AND Operator The AND operator accepts two conditions and returns true or false based on their evaluation only when all conditions are met it will return true, otherwise false: SELECT 1 = 1 AND 'test' = 'test'; # true SELECT 1 = 1 AND 'test' = 'abc'; # false In MySQL terms, any non-zero value is considered true, and it usually returns the value 1 to indicate true. 0 is considered false. As we can see in the example above, the first query returned true because both expressions evaluated to true. However, the second query returned false as the second condition 'test' = 'abc' is false. OR Operator The OR operator also takes two expressions, and returns true when at least one of them evaluates to true: SELECT 1 = 1 OR 'test' = 'abc'; # true SELECT 1 = 2 OR 'test' = 'abc'; # false NOT operator The NOT operator simply replaces a Boolean value 'ie. Truth is converted into falsehood and vice versa': SELECT NOT 1 = 1; # false SELECT NOT 1 = 2; # true As you can see in the examples above, the first query returned false because it is the inverse of the evaluation of 1 = 1, which is true, so its inverse is false. On the other hand, the second query was the one that returned true, since the inverse of 1 = 2 'which is false' is true. The AND, OR and NOT operators can also be represented as &&, || and !, respectively. Here are the same previous examples, using the symbol operators

#Web School 26