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
Transaction Control The Oracle is transaction oriented; that is, Oracle uses the transactions to make sure the data integrity. The transaction is a sequence of SQL data manip

Use the NOCOPY Compiler Hint By default, the OUT and IN OUT parameters are passed by the value i.e. the value of an IN OUT actual parameter is copied into the corresponding fo

EXCEPTION_INIT Pragma The pragma EXCEPTION_INIT relates an exception name with an Oracle error number. Which allow you to refer to any internal exception by the name and to wri

Anatomy of a Command Figure, showing a simple SQL command, is almost identical to its counterpart in the theory book. The only difference arises from the fact that SQL uses a

Explicitly specifying the join condition - SQL SELECT * FROM IS_CALLED JOIN IS_ENROLLED_ON ON ( IS_CALLED.StudentId = IS_ENROLLED_ON.StudentId ) Now, the key word JO

The Package Specification The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to t

Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illu

BIOCHE M ICA L ORIGIN OF LIFE - It is generally agreed by astronomers, geologists and biologists that the earth is approximately 4500-5000 million years old. It is an

Parameter and Keyword Description: select_item: This select_item is a value returned by the SELECT statement, and then assigned to the equivalent variable or field in the

Defining REF CURSOR Types To make cursor variables, you take 2 steps. At first, you define a REF CURSOR type, and then declare the cursor variables of that type. You can defin