DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Help with a select statement, please!

  1. #1
    Join Date
    Sep 2001
    Posts
    42
    Is there a way to make the following select statement work?

    SELECT hsn, location, location_desc
    FROM samples, locations
    WHERE samples.location_seq = locations.location_seq
    and hsn = &hsn;

    ERROR at line 1:
    ORA-00918: column ambiguously defined

    SQL> describe samples

    Name Null? Type
    ------------------------------- -------- ----
    HSN NOT NULL NUMBER(10)
    LOCATION VARCHAR2(20)
    LOCATION_SEQ NUMBER(6)


    SQL> describe locations

    Name Null? Type
    ------------------------------- -------- ----
    LOCATION NOT NULL VARCHAR2(20)
    LOCATION_SEQ NOT NULL NUMBER(6)
    LOCATION_TYPE VARCHAR2(12)
    LOCATION_DESC VARCHAR2(250)


    Thank you,

    mcorbin

  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    SELECT hsn, samples.location, location_desc
    FROM samples, locations
    WHERE samples.location_seq = locations.location_seq
    and hsn = &hsn;

    ?


  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Originally posted by mcorbin
    Is there a way to make the following select statement work?

    SELECT hsn, location, location_desc
    FROM samples, locations
    WHERE samples.location_seq = locations.location_seq
    and hsn = &hsn;

    ERROR at line 1:
    ORA-00918: column ambiguously defined

    SQL> describe samples

    Name Null? Type
    ------------------------------- -------- ----
    HSN NOT NULL NUMBER(10)
    LOCATION VARCHAR2(20)
    LOCATION_SEQ NUMBER(6)


    SQL> describe locations

    Name Null? Type
    ------------------------------- -------- ----
    LOCATION NOT NULL VARCHAR2(20)
    LOCATION_SEQ NOT NULL NUMBER(6)
    LOCATION_TYPE VARCHAR2(12)
    LOCATION_DESC VARCHAR2(250)


    Thank you,

    mcorbin
    LOCATION is in both tables. You need to specify something like:
    SELECT s.hsn, s.location, l.location_desc
    FROM samples s, locations l
    WHERE s.location_seq = l.location_seq
    and s.hsn = &hsn;
    Jeff Hunter

  4. #4
    Join Date
    Sep 2001
    Posts
    42
    Thanks Jeff,

    You would have thought I could have figured that out, I should be banished to the dbasupport.com dungeon.

    Thanks again,

    mcorbin

Posting Permissions

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


Click Here to Expand Forum to Full Width