Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 33 - Modular_V2.0_SQL_Flipbook
P. 33

    Using IN Operator

                         SELECT * FROM PRODUCTS WHERE Brand IN ('Montblanc','Parker');
                                 +------------+--------------+-----------+-------+-----------+
                                 | Product_id | Product_name | Brand     | Price | Status    |
                                 +------------+--------------+-----------+-------+-----------+
                                 | P101       | Pen          | Montblanc |   100 | Available |
                                 +------------+--------------+-----------+-------+-----------+
                                 | P102       | Pencil       | Parker    |    50 | Available |
                                 +------------+--------------+-----------+-------+-----------+
                     Using LIKE Operator

                     You can use the wildcards (*_and %) with the WHERE clause to specify condition. The *_wildcard
                     denotes a single character, on the other hand the % wildcard denotes the multiple characters:

                         SELECT Product_name,Price FROM PRODUCTS WHERE Brand LIKE 'c%';

                                                    +--------------+-------+
                                                    | Product_name | Price |
                                                    +--------------+-------+
                                                    | Geometry Box |   200 |
                                                    +--------------+-------+
                         SELECT Price FROM PRODUCTS WHERE Product_name LIKE 'p%';
                                                                   +-------+
                                                                   | Price |
                                                                   +-------+
                                                                   | 100   |
                                                                   +-------+
                                                                   |  50   |
                                                                   +-------+
                         MYSQL COMMENTS

                     Comments are used by programmers to explain the code they are creating in order to make it
                     understandable for others. This code is non executable and carry only representational purpose.

                     There are two types of Comments used in SQL statements:
                     1.   Single Line Comments: It begins with -- (Two hyphens) and anything written on the next line
                         once enter key is pressed is not a part of that comment and is considered executable code.

                         Example:

                         -- This is a single line comment.
                         Select * from PRODUCTS;

                     2.   Multi-line Comments: It  begins with  /*  and  ends  with  */.  Any  text  in between  will not  be
                         executable.

                         Example:
                              /* This is a multi-line comment.

                              The comment still continues.
                              It will end now. */

                              Select * from PRODUCTS;

                                                                                                                         31
                                                                                              Handling Records in MySQL

| 28 29 30 31 32 33 34 35 36 37 38 |