Home  >  Q&A  >  body text

How can I get the complete list of all book categories in the table?

I have a "Books" table that looks like this:

I'm trying to make a Spring Boot application that lists all these books but you can filter them by category. To do this, I want to display a list of each category so the user can click on the category they want.

What is a better way to get a list of this category? For example, in the case of the picture above, I want to display a list like this:

P粉681400307P粉681400307204 days ago313

reply all(1)I'll reply

  • P粉745412116

    P粉7454121162024-03-29 15:54:26

    You can view

    @Query annotation @lemon provided the solution

    @Query("SELECT DISTINCT category FROM Books")
    List categories();

    You can also check this

    reply
    0
  • Cancelreply