SELECT many to many tables in one query

前端 未结 1 1251
别跟我提以往
别跟我提以往 2021-01-21 20:18

I have tables:

**RUBRIC:** `RubricID, RubricName`

**AUTOR:** `AutorID, FirstName, LastName`

**BOOK:** `BookID, BookName, book_photo`

**BOOKAUTOR:** `BookID, A         


        
相关标签:
1条回答
  • 2021-01-21 20:56

    Try this query

    SELECT book.BookName, autor.FirstName, autor.LastName, rubric.RubricName 
    FROM bookautor
    JOIN book ON book.BookID=bookautor.BookID 
    JOIN autor on autor.AutorID=bookautor.AutorID 
    left join bookrubric on book.BookID=bookrubric.BookID
    LEFT JOIN rubric ON rubric.RubricID=bookrubric.RubricID;
    
    0 讨论(0)
提交回复
热议问题