DEV Community

Cover image for One Commit at a Time ! Series - 26
Annapoorani Kadhiravan
Annapoorani Kadhiravan

Posted on Edited on

One Commit at a Time ! Series - 26

JAVA

public class Main {
  public static void main(String[] args) {
    int x = 5;
    System.out.println(x > 3 && x < 10); // returns true because 5 is greater than 3 AND 5 is less than 10
  }
}
Enter fullscreen mode Exit fullscreen mode

Explanation :

  1. int x = 5;
  2. Declares an integer variable named x and assigns it the value 5.

  3. x > 3

  4. Evaluates whether x (which is 5) is greater than 3. This statement is true.

  5. x < 10

  6. Evaluates whether x (which is 5) is less than 10. This statement is true.

  7. x > 3 && x < 10

  8. The && symbol is the logical AND operator. It requires both sides of the expression to be true for the entire condition to be true.

  9. Since 5 > 3 is true and 5 < 10 is true, the overall result of the expression is true.

  10. System.out.println(...)

  11. Prints the result of the expression (true) to the console.


SQL

All Conditions Must Be True
The following SQL selects all customers where Country is "Brazil" AND City is "Rio de Janeiro" AND CustomerID is higher than 50:

Example

SELECT * FROM Customers
WHERE Country = 'Brazil'
AND City = 'Rio de Janeiro'
AND CustomerID > 50;
Enter fullscreen mode Exit fullscreen mode

References:
https://www.w3schools.com/sql/sql_and.asp
https://www.w3schools.com/java/java_examples.asp

Top comments (0)