Sort columns by category

Asked

Viewed 27 times

0

I need to select and leave everything organized according to its category:

An example: https://novaframework.com/documentation/v2.2

My table is like this:

Categories:

inserir a descrição da imagem aqui

Articles:

inserir a descrição da imagem aqui

My query:

$query = "
    SELECT 
c.*,
a.*,
GROUP_CONCAT(a.title SEPARATOR '|') AS articles
FROM categories c
INNER JOIN articles a ON c.category_id = a.category_id
GROUP BY c.category_id";

With this query above it ends up like this:

inserir a descrição da imagem aqui

  • I don’t really understand what you want to do, but if you want to select all articles in order of category, just one: SELECT * FROM articles ORDER BY category_id

  • @Joãobolsson, I need to return each article within its id, notice that in Categories, you have, starting, the basics and helpers I will edit the topic with my query

  • Take a look at this topic: https://answall.com/questions/293484/display-products-de-v%C3%A1rias-categorias é o que você precisa

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.