How do I set the last SECTION number of the CHAPTER of a BOOK as a LIMIT? i.e. When I search for a BOOKNAME in a search box, I want to output all the SECTION(s) of the FIRST CHAPTER of the BOOKNAME with a LINK to the NEXT CHAPTER.
MySQL code to query a BOOKNAME from two TABLES:
SELECT t1.name,
t2.chapter,
t2.section,
t2.text
FROM books t1
JOIN sections t2
ON t1.id = t2.book
WHERE t1.name = '$bookname'
MySQL code to query a BOOKNAME from two TABLES and getting the last SECTION number of all the CHAPTERS of a BOOKNAME:
SELECT t1.name,
t2.chapter,
Max(t2.section) as sMax,
t2.text
FROM books t1
JOIN sections t2
ON t1.id = t2.book
WHERE t1.name = '$bookname'
GROUP BY t2.chapter