• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with MySQL statistics with Codeigniter

#1
I have this scenario in my application: a database with 4 main tables. They are:

brands
categories
categories_to_product
products

Between brands table and products table there is a one to many relation. Of course, there is a join field in products table that let me to relate the two tables named brand_id.

Between categories table and products table there is a many to many relation, and both tables use the categories_to_product table for to have the many to many relation. In the join table there is a composed PK with two fields, category_id and product_id.

So far so good.

Now, my goal is to have some statistics, and this is a field too difficult for my sql knowledge.

I'd like to achieve this kind of data:
- the first ten brands with more products related
- the first ten categories with more products related

I neither know from where I have to start, can someone tell me in what direction do I Have to go for to start?

Thank you in advance.

Giorgio.
Reply

#2
(06-08-2017, 09:28 AM)gbwebapps Wrote: I'd like to achieve this kind of data:
- the first ten brands with more products related
- the first ten categories with more products related

Can u explain this more clearly. more products related? related to what?
Reply

#3
The brands with more products related with itselves
The categories with more products related with itselves

for example...

1) samsung(22)
2) apple(19)
3) hewlett packard(13)
.....
.....

or

1) smartphones(22)
2) tablets(19)
3) pc desktop(13)

between parentheses the number of the products related....
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.