I would like to group the table below and return parts_number while checking the option value.
That is, for parts with same parts_number, same option value be grouped together. No mixing parts_number with different option values.
parts | parts_number | option
A | 100 |1
B | 120 |1
A | 100 |0
C | 110 |1
B | 120 |1
C | 110 |0
A | 100 |0
A | 100 |0
A | 100 |1
In the case above I should have my results returning rows as below:
parts | parts_number | option
A | 100 |1
B | 120 |1
A | 100 |0
C | 110 |1
C | 110 |0
A => 2
B => 1
C => 2
Note the grouping while not mixing parts of different options.
I have tried to group_by parts_number but I am stuck at the point where I have to cater for my options too.
I am using PHP (CodeIgniter) and MySQL. Any help is highly appreciated.
should work.