Page 4 - Simple Queries in SQL
P. 4

TEXT      Values are treated as   TINYTEXT          Maximum length of 255 characters.
                           character strings having  TEXT            Maximum length of 65535
                           a character set.                          characters.
                                                   MEDIUMTEXT        Maximum length of 16777215
                                                                     characters.
                                                   LONGTEXT          Maximum length of 4294967295
                                                                     characters

               ENUM Types
               A string object whose value is chosen from a list of values given at the time of table creation. For
               example -
               CREATE TABLE length (     length ENUM('small', 'medium', 'large') );
               and only those values (or NULL) could ever populate that field, enum values should be string in single
               quote.

               SET Types
               A string object having zero or more comma separated values (maximum 64). Values are chosen from
               a list of values given at the time of table creation.

               CHAR vs VARCHAR
                 CHAR                                     VARCHAR
                 Used to store character string value     Used to store variable length alphanumeric data.
                 of fixed length.
                 It can hold a maximum of 255 characters.   It can hold a maximum of 65,535 characters.
                 It's 50% faster than VARCHAR.            It's slower than CHAR.
                 It uses static memory allocation.        It uses dynamic memory allocation

               NULL value
                   •   No value in a cell is NULL/null value.
                   •   Its not equal to zero(ZERO ≠ NULL)
                   •   Any arithmetic expression containing a NULL always evaluates to NULL.
                   •   When displaying the content of a table if a cell contain null value MySQL display it as NULL.

               SQL operators
               Relational Operators are:
                       <, <=, >, >=, =, != (<>)
               Logical operators are:
                       AND (&&),  OR (II),  NOT(!)


               SELECT Statement Basics

               The SQL SELECT statement queries data from tables in the database. The statement begins with the
               SELECT keyword. The basic SELECT statement has 3 clauses:
                   •   SELECT
                   •   FROM
                   •   WHERE
               General format is:
                       select <col1>, <col2>,…………,<col n>
                       from <table1>, <table2>
                       where <condition>
   1   2   3   4   5   6   7   8   9