'CA') : AND OR « Query Select « Oracle PL/SQL Tutorial'> 'CA') : AND OR « Query Select « Oracle PL/SQL Tutorial'>

(state = 'CA') OR (state <> 'CA') : AND OR « Query Select « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE publishers(
  2    pub_id   CHAR(3)     NOT NULL,
  3    pub_name VARCHAR(20) NOT NULL,
  4    city     VARCHAR(15) NOT NULL,
  5    state    CHAR(2)     NULL    ,
  6    country  VARCHAR(15) NOT NULL);

Table created.

SQL>
SQL> INSERT INTO publishers VALUES('P01','A','New York','NY','USA');

1 row created.

SQL> INSERT INTO publishers VALUES('P02','C','San Francisco','CA','USA');

1 row created.

SQL> INSERT INTO publishers VALUES('P03','S','Hamburg',NULL,'Germany');

1 row created.

SQL> INSERT INTO publishers VALUES('P04','T','Berkeley','CA','USA');

1 row created.

SQL>
SQL>
SQL>
SQL> SELECT pub_id, pub_name, state, country
  2    FROM publishers
  3    WHERE (state = 'CA') OR (state <> 'CA');

PUB PUB_NAME             ST COUNTRY
--- -------------------- -- ---------------
P01 A                    NY USA
P02 C                    CA USA
P04 T                    CA USA

SQL>
SQL> drop table publishers;

Table dropped.

SQL>
SQL>








2.11.AND OR
2.11.1.Use AND to link two conditions
2.11.2.Use 'OR' to link two conditions
2.11.3.Combine three conditions with OR
2.11.4.(state = 'CA') OR (state <> 'CA')
2.11.5.1=1 or 1=0 and 0=1 (case 1)
2.11.6.(1=1 or 1=0) and 0=1 (case 2)
2.11.7.1=1 or (1=0 and 0=1) (case 3)
2.11.8.CONDITION
2.11.9.Combine NOT and AND
2.11.10.Not Equal and OR
2.11.11.Replace IN operator with or operator
2.11.12.Combine conditions with AND and OR
2.11.13.Use parenthesis to change the order of AND and OR