The basic query is going to be the below

select stuff
from

books
inner join author_books
    on author_books.book_isbn = books.book_isbn
inner join author
    on author_books.author_id = author.author_id

where things;



-----Original Message-----
From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On Behalf Of 
dboland9
Sent: Tuesday, August 27, 2019 9:38 AM
To: sqlite-users@mailinglists.sqlite.org
Subject: [sqlite] Query for Many to Many

All,

I need some help writing some queries for a MTM relationship.  The example 
tables are:

author table         books table         author_books table
    author_id PK        book_isbn PK        a_b_id PK
    author_fname        book_title          author_id FK
    author_lname        book_pub_date       book_isbn FK
    author_minit


Listings desired:
    book_isbn   book_title  book_pub_date   author
    ----------+------------+--------------+-----------
   
    author     book_isbn    Book_title
    --------+-------------+------------

Would appreciate the query (inner join - that I do know), and why so I can 
learn something from them.  Please keep them simple (no alias or other 
shortcuts) so I can easily follow what you are doing.  Thanks in advance.

I assume the query will be something like:
  SELECT
    books.book_isbn, books.book_title, books.book_pub_date,
    author.author_fname, author.author_minit,
    author.author_lname
  FROM books
  JOIN
    author_books ON (something )

Dave,



Sent with ProtonMail Secure Email.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to