AND,&&

Description

Logical AND,&&. Evaluates to true if all operands are nonzero and not NULL, to false if one or more operands are 0, otherwise NULL is returned.

Syntax

  1. > SELECT column_1 AND column_2 FROM table_name;

Examples

  1. > select 1 and 1;
  2. +---------+
  3. | 1 and 1 |
  4. +---------+
  5. | true |
  6. +---------+
  7. > select 1 and 0;
  8. +---------+
  9. | 1 and 0 |
  10. +---------+
  11. | false |
  12. +---------+
  13. > select 1 and null;
  14. +------------+
  15. | 1 and null |
  16. +------------+
  17. | NULL |
  18. +------------+
  19. > select null and 0;
  20. +------------+
  21. | null and 0 |
  22. +------------+
  23. | false |
  24. +------------+
  25. 1 row in set (0.01 sec)
  1. > create table t1 (a boolean,b bool);
  2. > insert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);
  3. > select * from t1;
  4. > select a and b from t1;
  5. +---------+
  6. | a and b |
  7. +---------+
  8. | false |
  9. | false |
  10. | true |
  11. | false |
  12. | NULL |
  13. +---------+
  14. 5 rows in set (0.00 sec)