Page 32 - Modular_V2.0_SQL_Flipbook
P. 32

Operator                                          Description
                              The IN Operator returns true if the operand is equal to any of the values in the
                     IN
                              expression.
                              The LIKE operator in SQL searches for a character string that matches the specified
                    LIKE
                              pattern using wildcards in a column.

              Let's use some of the operators by taking the following tables:
                                                         Table-PRODUCTS

                   Product_id       Product_name               Brand                  Price             Status
                      P101         Pen                 Montblanc                       100         Available
                      P102         Pencil              Parker                          50          Available
                      P103         Eraser              Tombow Mono Sand                20          Available
                      P104         Geometry Box        Camlin                          200         Available

                                                      Table-ORDER_DETAIL

                                Product_id          Quantity           Amount            Order_ID
                                    P101               100               10000            Or11001
                                    P102               200               10000            Or11005
                                    P103               150               3000             Or11010
                                    P104                75               15000            Or11016

              Using ALL Operator
                   SELECT Product_name
                   FROM PRODUCTS
                   WHERE Product_id = ALL (SELECT Product_id FROM ORDER_DETAIL
                   WHERE Quantity < 100);
                                                        +--------------+
                                                        | Product_name |
                                                        +--------------+
                                                        | Geometry Box |
                                                        +--------------+
              Using ANY Operator
                   SELECT * FROM PRODUCTS
                   WHERE Price > ANY (SELECT Price FROM PRODUCTS WHERE Price > 50);
                            +------------+--------------+--------+-------+-----------+
                            | Product_id | Product_name | Brand  | Price | Status    |
                            +------------+--------------+--------+-------+-----------+
                            | P104       | Geometry Box | Camlin | 200   | Available |
                            +------------+--------------+--------+-------+-----------+
              Using BETWEEN Operator
                   SELECT * FROM PRODUCTS WHERE Price BETWEEN 50 AND 100;
                          +------------+--------------+-----------+-------+-----------+
                          | Product_id | Product_name | Brand     | Price | Status    |
                          +------------+--------------+-----------+-------+-----------+
                          | P101       | Pen          | Montblanc | 100   | Available |
                          +------------+--------------+-----------+-------+-----------+
                          | P102       | Pencil       | Parker    |  50   | Available |
                          +------------+--------------+-----------+-------+-----------+

                30
                      Touchpad MODULAR (Ver. 2.0)
   27   28   29   30   31   32   33   34   35   36   37