Sql Operators

THE NOT OPERATOR
The NOT operator is used in combination with other operators to give the opposite result, also called the negative result.
Syntax:

SELECT column1, column2, …
FROM table_name
WHERE NOT condition;

Example:

select * from order_products1;
select Order_Code,Order_Name from order_products1 where not Order_Code=101 and order_code=105;

Insert Into:

select * from order_products1;

    • The insert into statement is used to add new data to a database. Insert into adds a new record to a table. It can contain values for some or all of its columns and it can be combined with a select to insert records.Syntax:

      INSERT INTO table_name (column1, column2, column3, …)
      VALUES (value1, value2, value3, …);

Example:

  • Inserted a new record order_code=116 as shown below

    IS NULL:

    A field with a NULL value is a field with no value. A Null value is different from zero value or a field that contain spaces. A field with a Null value is one that has been left blank during record creation.

    Syntax:

    SELECT column_names
    FROM table_name
    WHERE column_names is NULL;

    Example:

    Select * from ORDER_PRODUCTS1;

    select * from order_products1;

    select * from order_products1 where item_cost is Null;

    IS NOT NULL:

    The IS NOT NULL operator is used to test for non-empty values (NOT NULL values).

    Syntax:

    SELECT column_names
    FROM table_name
    WHERE column_name IS NOT NULL;

    Example:

    select * from order_products1;

    select * from order_products1 where item_cost is not null;