1
나는 select, title, bookcopiesid, 그리고 name을 가지고있다.카운트와 서브 선택
select
books.title, borrow.bookcopiesid, users.name, usersid,library_locations.name, checkout_date, return_date, due_date
FROM
books, borrow,users, library_locations, userlib
WHERE
library_locations.id = userlib.libid
AND
userlib.userid = users.id
AND
borrow.bookcopiesid = books.bookid
AND
borrow.usersid = users.id and return_date is not null ;
어떻게 작동하는
SELECT title, COUNT(*) as count
FROM (
SELECT books.title, borrow.bookcopiesid, users.name, usersid,library_locations.name, checkout_date, return_date, due_date
FROM books, borrow,users, library_locations, userlib
WHERE library_locations.id = userlib.libid and userlib.userid = users.id and borrow.bookcopiesid = books.bookid and borrow.usersid = users.id and return_date is not null)
GROUP BY title
ORDER BY count DESC);
같은 것을 얻을 것입니다.
i는 각각의 이름
테이블 구조와 게시하려는 출력 샘플을 게시하면 도움이됩니다. – bobwienholt