Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006
    Posts
    1

    Unanswered: Difference between normal query and inner join

    Hi
    I have 2 tables.
    fields are
    Employee,

    1. empid
    2. empname
    3. deptid


    Department
    1. deptid
    2. deptname


    I want to show empid, empname, deptname

    Two ways i can select the details, one way is normal query using where and another way is using joins.

    1. select a.empid, a.empname, b.deptname from employee a, department b where a.deptid = b.deptid;


    or
    1. select a.empid, a.empname, b.deptname from employee a inner join department on a.deptid = b.deptid;


    What is the advantage of using join. & tell me the difference if any?

    Its urgent

    Thanks in advance.

    regards
    MINIL

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    advantage: clarity and ease of understanding, also it is standard sql

    no performance difference for INNER JOIN

    pretty difficult to write an outer join without OUTER JOIN syntax
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Also, depending upon the complexity of the query; explicit joins (with PostgreSQL) also explicitly direct PG's query planner, whereas where queries have their query plan chosen by PG, which MAY not result in the most effecient query plan.

    In other words, an explicit join instead of a where clause, results in an unambiguous join order to the query planner.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •