Inner join, PL-SQL Programming

Inner Join

We have learned how to retrieve data from one table by using SELECT statement. But, as we have learned, normalized relational databases mean the data is spread between multiple related tables. Consequently, we need to learn how to select data from more than just one table. To get complete sets of data, we will need to use the SQL JOIN clause in SELECT statement. The normal form of SQL JOIN clause in MySQL is shown here:

 SELECT column_list FROM table_1

 [INNER | LEFT | RIGHT] table_2 ON conditions_2

 [INNER | LEFT | RIGHT] table_3 ON conditions_3 ...

 WHERE conditions

After SELECT keyword is a list of column names from which you want to retrieve the data. These columns have to be in the tables you select such as table_1, table_2... It is a best practice to explicitly declare the column using the table_name.column_name syntax. This will prevent a scenario where the same column name occurs in multiple tables, causing an ambiguous reference. Next you will list the main table and then a list of table you want to join. You can use INNER JOIN, LEFT JOIN or RIGHT JOIN. You can join a table with more than two tables or even with itself. In the JOIN clause you have to declare the join conditions. If all the conditions on each join clause match, MySQL will return the corresponding data.

Posted Date: 2/16/2013 8:13:40 AM | Location : United States

Related Discussions:- Inner join, Assignment Help, Ask Question on Inner join, Get Answer, Expert's Help, Inner join Discussions

Write discussion on Inner join
Your posts are moderated
Related Questions
which operation is used if we are interested in only certain columns of a table?

Using EXTEND To enlarge the size of a collection, use EXTEND. This process has 3 forms. The EXTEND appends one null element to a collection. And the EXTEND(n) appends n null e

Ending Transactions A good quality programming practice is to commit or roll back every transaction explicitly. Whether you rollback or issue the commit in your PL/SQL program

Organi c Evolution Evolution is a slow continuous, irreversible and natural process of change to give rise to advance and diverse forms of life i.e. formation of new specie

DBMS: The answer to this question is of course given in of the theory book. This book is concerned with SQL DBMSs and SQL databases in particular. Soon we will be looking a

Boolean Values Only the values TRUE, FALSE, & NULL can be assigned to a Boolean variable. For illustration, given the declaration DECLARE done BOOLEAN; the following statements

Loop Labels Like the PL/SQL blocks, loops can also be labeled. The label, an undeclared identifier enclosed by double angle brackets, should appear at the beginning of the LOOP

Use of COUNT in SQL It describes and discusses various general methods of expressing constraints, eventually noting that support for "=" with relation operands is sufficient f

Object Type: The object type is a user-defined composite datatype which encapsulates a data structure along with the functions and procedures required to manipulate the data

SQL Functions The PL/SQL uses all the SQL functions involving the following aggregate functions that summarize the whole columns of the Oracle data: GROUPING, AVG, COUNT, STDDE