On Sun, 8 Jan 2017 04:21:16 -0600, Ken Wagner
<beauco...@gmail.com> wrote:

>Hello SQLusers,
>
> The error below occurs even though the
>
> CREATE TABLE track(
>
>   trackid     INTEGER,
>   trackname   TEXT,
>   trackartist INTEGER,
>   *FOREIGN KEY(trackartist) REFERENCES artist(artistid)*
> );
>
> statement at https://sqlite.org/foreignkeys.html was observed.
>
> It appears that 'trackerartist' should be named 'artistid'.
>
> SQLite3 CLI results using version SQLite 3.15.2 2016-11-28 19:13:37 
> bbd85d235f7037c6a033a9690534391ffeacecc8
>
> sqlite> select artistname, trackname from artist inner join track using 
> (trackartist);
> Error:\ cannot join using column trackartist - column not present in 
> both tables
> sqlite> .tables track
> track
> sqlite> .schema track
> CREATE TABLE track(
>   trackid     INTEGER,
>   trackname   TEXT,
>   trackartist INTEGER,
>   FOREIGN KEY(trackartist) REFERENCES artist(artistid)
> );
> sqlite> .schema artist
> CREATE TABLE artist(
>   artistid    INTEGER PRIMARY KEY,
>   artistname  TEXT
>
> Am I missing something important here?

The error message is quite informative: the artist table does
not have a column trackartist.

Try:
select artistname, trackname from artist inner join track on
trackartist = artistid;

HTH

-- 
Regards,
Kees Nuyt
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to