diff --git a/book.php b/book.php index 6832643..cc9896d 100644 --- a/book.php +++ b/book.php @@ -19,7 +19,7 @@ define ('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = book left outer join books_ratings_link on books_ratings_link.book = books.id left outer join ratings on books_ratings_link.rating = ratings.id "); define ('SQL_BOOKS_BY_FIRST_LETTER', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " - where upper (books.sort) like ?"); + where upper (books.sort) like ? order by books.sort"); define ('SQL_BOOKS_BY_AUTHOR', "select {0} from books_authors_link, books " . SQL_BOOKS_LEFT_JOIN . " where books_authors_link.book = books.id and author = ? {1} order by pubdate"); define ('SQL_BOOKS_BY_SERIE', "select {0} from books_series_link, books " . SQL_BOOKS_LEFT_JOIN . " @@ -29,7 +29,7 @@ define ('SQL_BOOKS_BY_TAG', "select {0} from books_tags_link, books " . SQL_BOOK define ('SQL_BOOKS_BY_CUSTOM', "select {0} from {2}, books " . SQL_BOOKS_LEFT_JOIN . " where {2}.book = books.id and {2}.{3} = ? {1} order by sort"); define ('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " - where (exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or title like ?) {1}"); + where (exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or title like ?) {1} order by books.sort"); define ('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " where 1=1 {1} order by timestamp desc limit ");