Tec&Cult
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Tec&Cult

Technologie et Culture
 
AccueilAccueil  PortailPortail  GalerieGalerie  Dernières imagesDernières images  RechercherRechercher  S'enregistrerS'enregistrer  Connexion  
Sujets similaires
    Rechercher
     
     

    Résultats par :
     
    Rechercher Recherche avancée
    Derniers sujets
    » Que faire à Paris le week-end du 15 août ?
    SQL Equi Joins: EmptyJeu 11 Aoû - 11:20 par Admin

    » T-shirt Mec de Paname
    SQL Equi Joins: EmptyMer 3 Aoû - 17:04 par Admin

    » dating web site uk dating free parent single
    SQL Equi Joins: EmptyMer 3 Aoû - 10:56 par Invité

    » rsvp dating website seeking bisexual
    SQL Equi Joins: EmptyLun 1 Aoû - 2:08 par Invité

    » dating french woman gay bottom seeking tops
    SQL Equi Joins: EmptyDim 31 Juil - 21:59 par Invité

    » dating philippine woman man seeking wealthy woman
    SQL Equi Joins: EmptyVen 29 Juil - 12:51 par Invité

    » dating lesbian n r cacee cobb dating lachey nick
    SQL Equi Joins: EmptyVen 29 Juil - 3:17 par Invité

    » single dating chat room relationship dating advice
    SQL Equi Joins: EmptyJeu 28 Juil - 0:21 par Invité

    » скачать порно тетя скачать порнофото семейное
    SQL Equi Joins: EmptyJeu 21 Juil - 14:34 par Invité

    Navigation
     Portail
     Index
     Membres
     Profil
     FAQ
     Rechercher
    Forum
    Partenaires
    Forum gratuit


    Tchat Blablaland
    -28%
    Le deal à ne pas rater :
    Précommande : Smartphone Google Pixel 8a 5G Double Sim 128Go ...
    389 € 539 €
    Voir le deal

    Partagez | 
     

     SQL Equi Joins:

    Voir le sujet précédent Voir le sujet suivant Aller en bas 
    AuteurMessage
    Admin
    Admin


    Messages : 156
    Date d'inscription : 20/05/2010

    SQL Equi Joins: _
    MessageSujet: SQL Equi Joins:   SQL Equi Joins: EmptyJeu 23 Juin - 15:54

    http://toptech.geekaddict.net/
    1) SQL Equi Joins:

    An equi-join is further classified into two categories:
    a) SQL Inner Join
    b) SQL Outer Join
    a) SQL Inner Join:

    All the rows returned by the sql query satisfy the sql join condition specified.

    For example: If you want to display the product information for each order the query will be as given below. Since you are retrieving the data from two tables, you need to identify the common column between these two tables, which is theproduct_id.

    The query for this type of sql joins would be like,

    SELECT order_id, product_name, unit_price, supplier_name, total_units
    FROM product, order_items
    WHERE order_items.product_id = product.product_id;

    The columns must be referenced by the table name in the join condition, because product_id is a column in both the tables and needs a way to be identified. This avoids ambiguity in using the columns in the SQL SELECT statement.

    The number of join conditions is (n-1), if there are more than two tables joined in a query where 'n' is the number of tables involved. The rule must be true to avoid Cartesian product.

    We can also use aliases to reference the column name, then the above query would be like,

    SELECT o.order_id, p.product_name, p.unit_price, p.supplier_name, o.total_units
    FROM product p, order_items o
    WHERE o.product_id = p.product_id;

    b) SQL Outer Join:

    This sql join condition returns all rows from both tables which satisfy the join condition along with rows which do not satisfy the join condition from one of the tables. The sql outer join operator in Oracle is ( + ) and is used on one side of the join condition only.

    The syntax differs for different RDBMS implementation. Few of them represent the join conditions as "sql left outer join", "sql right outer join".

    If you want to display all the product data along with order items data, with null values displayed for order items if a product has no order item, the sql query for outer join would be as shown below:

    SELECT p.product_id, p.product_name, o.order_id, o.total_units
    FROM order_items o, product p
    WHERE o.product_id (+) = p.product_id;

    The output would be like,

    product_id product_name order_id total_units
    ------------- ------------- ------------- -------------
    100 Camera
    101 Television 5103 10
    102 Refrigerator 5101 5
    103 Ipod 5102 25
    104 Mobile 5100 30
    NOTE:If the (+) operator is used in the left side of the join condition it is equivalent to left outer join. If used on the right side of the join condition it is equivalent to right outer join.

    SQL Self Join:

    A Self Join is a type of sql join which is used to join a table to itself, particularly when the table has a FOREIGN KEY that references its own PRIMARY KEY. It is necessary to ensure that the join statement defines an alias for both copies of the table to avoid column ambiguity.

    The below query is an example of a self join,

    SELECT a.sales_person_id, a.name, a.manager_id, b.sales_person_id, b.name
    FROM sales_person a, sales_person b
    WHERE a.manager_id = b.sales_person_id;

    2) SQL Non Equi Join:

    A Non Equi Join is a SQL Join whose condition is established using all comparison operators except the equal (=) operator. Like >=, <=, <, >

    For example: If you want to find the names of students who are not studying either Economics, the sql query would be like, (lets use student_details table defined earlier.)

    SELECT first_name, last_name, subject
    FROM student_details
    WHERE subject != 'Economics'

    The output would be something like,

    first_name last_name subject
    ------------- ------------- -------------
    Anajali Bhagwat Maths
    Shekar Gowda Maths
    Rahul Sharma Science
    Stephen Fleming Science
    Revenir en haut Aller en bas
    http://toptech.geekaddict.net
     

    SQL Equi Joins:

    Voir le sujet précédent Voir le sujet suivant Revenir en haut 
    Page 1 sur 1

    Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
    Tec&Cult :: Informatique :: Oracle :: Oracle PL SQL-
    Sauter vers: