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
Datatype Conversion At times it is necessary to convert a value from one datatype to another. For e.g. if you want to inspect a rowid, you should convert it to a character stri

Using %TYPE The %TYPE attribute gives the datatype of a variable or the database column. In the example below, the %TYPE gives the datatype of a variable: credit REAL(7,2); debi

EXIT The EXIT statement forces a loop to done unconditionally. Whenever an EXIT statement is encountered, the loop is done immediately and controls the passes to the next statem

Built-In Functions The PL/SQL provides a lot of powerful functions to help you to manipulate the data. These built-in functions fall into the categories as shown below: error r

User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai

Cursors The Oracle uses work areas to execute the SQL statements and to store process information. A PL/SQL construct known as the cursor. Let's you assume name a work area and

Define basic operators of relational algebra with an example each

Using research notes and Oracle documentation plan and execute an upgrade of an installation of Oracle 10g to Oracle 11g release 1. To do this you must show in screen shots and wri

Implicit Cursor Attributes The Implicit cursor attributes returns the information about the execution of an INSERT, DELETE, UPDATE, or SELECT INTO statement. The cursor attribu

Example of Check Constraints Example: Workaround for when subqueries not permitted in CHECK constraints CREATE FUNCTION NO_MORE_THAN_20000_ENROLMENTS ( ) RETURNS BOOLEAN