I have a database structure given below
id | Title | brand |
---+---------+-------+
1 |product1 | Lg |
2 |pruduct2 | Lg |
3 |pruduct3 | Lg |
4 |pruduct4 | Lg |
5 |pruduct5 | Lg |
6 |pruduct6 |samsung|
7 |pruduct7 |samsung|
8 |pruduct8 |samsung|
9 |pruduct9 |samsung|
10 |pruduct10|samsung|
11 |pruduct11| sony |
12 |pruduct12| sony |
13 |pruduct13| sony |
14 |pruduct14| sony |
15 |pruduct15| sony |
We need some query by which I can mix results by brands
Output should be like
id | Title | brand |
---+---------+-------+
1 |product1 | Lg |
6 |pruduct6 |samsung|
11 |pruduct11| sony |
2 |pruduct2 | Lg |
7 |pruduct7 |samsung|
12 |pruduct12| sony |
.... and so on
I have following query which can retrieve same result
select id, title,brand row_number() over (partition by brand_id) as
row_num from product_test order by row_;
This doesn't work with MySql unfortunately Need a solution based on cakephp find or any other apporach
Thanks in advance