Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    15

    Unanswered: ORA-00918: column ambiguously defined

    I am getting error "ORA-00918: column ambiguously defined" while executing following query-

    SELECT ei.emp_name, ci.comp_name
    FROM comp_info ci
    INNER JOIN emp_info ei
    ON ci.comp_id = ei.comp_id
    WHERE comp_id = 11;


    I can't change last line 'WHERE comp_id = 11' as it is generated from background code.

    Any workaround?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT ei.emp_name
         , ci.comp_name
      FROM comp_info ci
    INNER 
      JOIN ( SELECT comp_id AS beelzebub
                  , emp_name
               FROM emp_info ) ei
        ON ei.beelzebub = ci.comp_id
     WHERE comp_id = 11;
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2012
    Posts
    15
    It worked

    thanks

Tags for this Thread

Posting Permissions

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