Share
Explore BrainMass

SQL inner joins and ambiguous field names

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;

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