SQL FROM tables

The Select FROM statement.

  • Since we can select the data from multiple tables using the FROM, same column names may exist in several of these tables.
  • To select a specific column from a table of several tables, we need to prefix the column name with the name of the table or use an ALIAS (short notation) for the name of the table.
    The syntax which are used to specify an alias for a table or view is:
    SELECT select_list
    FROM [qualifier.]{table_name | view_name} [AS] [alias]
    [, [qualifier.]{table_name | view_name} [AS] [alias] ]... 
    Example for one table:
    MySQL, Oracle, SQL server, PostgreSQL:
    select o.Order_ID as "Order", o.ISBN_no as "ISBN",
           o.Item_qty "Quantity", o.price "Price", o.Item_qty*price "Product" 
           from order_BOOKS o
           where o.order_ID=70001;
    The result should be:
    Order ISBN Quantity Price Product
    70001 0201703092 2 39 78
    70001 0764557599 1 42 42
    70001 1861002025 5 38 190
    70001 1861006314 2 29 58
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.