简体   繁体   中英

How do I join my result to retrieve another table's corresponding records?

(SELECT BOOKAUTHOR from (select DISTINCT bookauthor, genre from BOOK) group by bookauthor HAVING COUNT(*) > 1);

So confused about joins

please let me know if there is anyway to improve my question, i have tried to search and search and am still so confused to make this happen

You'd do something like

SELECT a.AUTHORFIRSTNAME,
       a.AUTHORLASTNAME
  FROM (SELECT BOOKAUTHOR, COUNT(*)
          FROM BOOK
          GROUP BY BOOKAUTHOR
          HAVING COUNT(*) > 1) b
  INNER JOIN AUTHOR a
    ON a.AUTHORID = b.BOOKAUTHOR

dbfiddle here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM