B
B
Binarix2015-07-05 12:27:40
PHP
Binarix, 2015-07-05 12:27:40

How to get data from the database by groups?

Hello. Tell me this is the moment.
there is a database table:
id, group, title, description
it stores data:
1, 1, clock, gold watch
2, 1, clock, simple clock
3, 2, clock, cuckoo clock,
you need to display data from it in an html document by categories from the "group" column, so that it looks like this:
Wrist
-gold clock
-simple clock
Wall
-cuckoo clock
You can, of course, use several queries, but I would like one with automatic categorization.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nApoBo3, 2015-07-05
@nApoBo3

If you just need a list of groups, then either from an external directory or distinct. If sorting by group before order by. group by groups data to get totals.

E
esy1993, 2015-07-05
@esy1993

select description as Wrist from tableName where group = 1
select description as Wall-mounted from tableName where group = 2
Two queries, but the problem is solved. How to stuff in html - I will not tell you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question