Posts

MySQL Alias Syntax

  SQL - Alias Syntax You can rename a table or a column temporarily by giving another name known as Alias . The use of table aliases is to rename a table in a specific SQL statement. The renaming is a temporary change and the actual table name does not change in the database. The column aliases are used to rename a table's columns for the purpose of a particular SQL query. Syntax The basic syntax of a table alias is as follows. SELECT column1, column2.... FROM table_name AS alias_name WHERE [condition]; The basic syntax of a column alias is as follows. SELECT column_name AS alias_name FROM table_name WHERE [condition]; Example Consider the following two tables. Table 1 − CUSTOMERS Table is as follows. +----+----------+-----+-----------+----------+ | ID | NAME      | AGE | ADDRESS    | SALARY    | +----+----------+-----+-----------+----------+ |   1 | Ramesh    |   32 | Ahmedabad | ...

MySQL NULL Value

  SQL - NULL Values The SQL NULL is the term used to represent a missing value. A NULL value in a table is a value in a field that appears to be blank. A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces. Syntax The basic syntax of NULL while creating a table. SQL> CREATE TABLE CUSTOMERS(    ID    INT               NOT NULL,    NAME VARCHAR (20)      NOT NULL,    AGE   INT               NOT NULL,    ADDRESS   CHAR (25) ,    SALARY    DECIMAL (18, 2),           PRIMARY KEY (ID) ); Here, NOT NULL signifies that column should always accept an explicit value of the given da...