Explore BrainMass
Share

Explore BrainMass

    SQL inner joins and ambiguous field names

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Why wont this query run and how would you write it correctly? Major hint: try and run the query (use the database attached to Week 2's lecture) ...
    you'll get an error message that should explain:

    SELECT isbn
    FROM books INNER JOIN order_lines ON books.isbn = order_lines.isbn;

    © BrainMass Inc. brainmass.com June 1, 2020, 5:15 pm ad1c9bdddf
    https://brainmass.com/computer-science/sql/sql-inner-joins-and-ambiguous-field-names-133162

    Attachments

    Solution Preview

    First let's look at the query in more detail:

    SELECT isbn
    FROM books INNER JOIN order_lines ON books.isbn = order_lines.isbn;

    The SELECT clause indicates which field(s) you want included in the result set. The fields are indicated by their name. In this case there is only one requested field and it's "isbn".

    The FROM clause indicates which tables we are selecting from. This particular FROM ...

    Solution Summary

    This solution demonstrates an inner join when the tables involved contain fields with the same name.

    $2.19

    ADVERTISEMENT