Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

NOTES

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

What is the difference between Equi Join and Inner Join in SQL?

An equijoin is a join with a join condition containing an equality operator. An


equijoin returns only the rows that have equivalent values for the specified
columns.

An inner join is a join of two or more tables that returns only those rows
(compared using a comparison operator) that satisfy the join condition.

Syntax:EQUI JOIN

SELECT column_list
FROM table1, table2....
WHERE table1.column_name =
table2.column_name;
or

SELECT *
FROM table1
JOIN table2
[ON (join_condition)]

INNER JOIN

SQL Code:

SELECT foods.item_name,foods.item_unit,
company.company_name,company.company_city
FROM foods
INNER JOIN company
ON foods.company_id =company.company_id;

SELECT *
FROM company
NATURAL JOIN foods;

SELECT *
FROM table1
LEFT [ OUTER ] JOIN table2
ON table1.column_name=table2.column_name;

public static void main(String args[])


{
Map<String, Integer> hm
= new HashMap<String, Integer>();

hm.put("a", new Integer(100));


hm.put("b", new Integer(200));
hm.put("c", new Integer(300));
hm.put("d", new Integer(400));

// Traversing through the map


for (Map.Entry<String, Integer> me : hm.entrySet()) {
System.out.print(me.getKey() + ":");
System.out.println(me.getValue());
}

import java.sql.*;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
OR
Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn = DriverManager.getConnection(URL, username, passwd);

Connection conn = DriverManager.getConnection(URL);

Iterator iterator = list.iterator();

System.out.println("List elements : ");

while (iterator.hasNext())
System.out.print(iterator.next() + " ");

ListIterator iterator = list.listIterator();

// Traversing the list in forward direction


System.out.println("Displaying list elements in forward direction : ");

while (iterator.hasNext())
System.out.print(iterator.next() + " ");

Statement executeQuery(String query) is used to execute Select queries and


returns the ResultSet.
Statement executeUpdate(String query) is used to execute Insert/Update/Delete
(DML) statements or DDL statements that returns nothing.
Statement execute(String query) is used to execute any SQL query and it returns
TRUE if the result is an ResultSet such as running Select queries.

Statement: Used for general purpose access to the database and executes a static
SQL query at runtime.
PreparedStatement: Used to provide input parameters to the query during execution.
CallableStatement: Used to access the database stored procedures and helps in
accepting runtime parameters

You might also like