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
GOTO Statement The GOTO statement branches to a label unconditionally. The label must be exclusive within its scope and should precede an executable statement or a PL/SQL block.

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

RETURN Statement The RETURN statement instantly completes the execution of a subprogram and returns control to the caller. The Execution then resumes with the statement below t

ROWID and UROWID Internally, every database table has a ROWID pseudo column that stores binary values known as rowids. Each rowid shows the storage address of a row. A physical

Why Use Cursor Variables ? Primarily, you use the cursor variables to pass the query result sets between the PL/SQL stored subprograms and different clients. Neither PL/SQL nor

Transactions in SQL BEGIN TRANSACTION, COMMIT, and ROLLBACK, SQL has the same syntax except for START in place of BEGIN. However, START TRANSACTION is used only for outermost

Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

SQL Pseudocolumns The PL/SQL recognizes the following SQL pseudocolumns, that returns the specific data items: LEVEL, NEXTVAL, CURRVAL, ROWID, & ROWNUM. The Pseudocolumns are n

which operation is used if we are interested in only certain columns of a table?

IN Operator The operator IN tests the set membership. This means "equal to any member of." The set may have nulls, but they are ignored. For illustration, the statement below do