2008/7/14 Ralf <[EMAIL PROTECTED]>: > I'm having problems with Inner Joins on m:n relations > > book <--> bookauthor <--> author > > SELECT authorname FROM author INNER JOIN book INNER JOIN bookauthor ON > book.Id_book = bookauthor.Id_book ON author.Id_author = bookauthor.Id_author > WHERE bookltitle='title' > > I receive an error when I execute this Query saying > > "SQL Error" > Is it me or is it SQLite? > > Or a bit of both? > Pls help me > Thanks > Ralf
Ralf, You just get the syntax of the joins right... SQLite version 3.5.9 Enter ".help" for instructions sqlite> sqlite> create table book( bookId integer, bookName text ); sqlite> create table author( authorId integer, authorName text ); sqlite> create table bookAuthor( bookId integer, authorId integer ); sqlite> insert into book values( 1, 'book1' ); sqlite> insert into book values( 2, 'book2' ); sqlite> insert into book values( 3, 'book3' ); sqlite> insert into book values( 4, 'book4' ); sqlite> sqlite> insert into author values( 1, 'author1' ); sqlite> insert into author values( 2, 'author2' ); sqlite> insert into author values( 3, 'author3' ); sqlite> sqlite> insert into bookAuthor values( 1, 1 ); sqlite> insert into bookAuthor values( 2, 1 ); sqlite> insert into bookAuthor values( 3, 2 ); sqlite> insert into bookAuthor values( 4, 3 ); sqlite> sqlite> select authorName from author inner join bookAuthor on author.authorId=bookAuthor.authorId inner join book on book.bookId=bookAuthor.bookId where bookName='book1'; author1 sqlite> select authorName from author inner join bookAuthor on author.authorId=bookAuthor.authorId inner join book on book.bookId=bookAuthor.bookId where bookName='book4'; author3 sqlite> Rgds, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users