Hello,

for example ;

i want to select 5 products per page with extra joins depending on client's choise.

if just from 1 table its Ok.

product 1
product 2
product 3
product 4
product 5

However if i want to take extra information from another table with join.
I got this. 5 records ,but 3 Products.

Product 1 - category 1
Product 1 - category 2
Product 1 - category 3
Product 2 - category 1
Product 3 - category 1

I should get

Product 1 - category 1
Product 1 - category 2
Product 1 - category 3
Product 2 - category 1
Product 3 - category 1
Product 4 - category 1
Product 4 - category 2
Product 5 - category 1
Product 5 - category 3

How could i get this in just 1 query?

I want to learn the logic.

In real world

PHP Code:
[0] => Array
        (
            [
id] => 44
            
[code] => 375641
            
[pic] => imag0298
            
[category] => Category 1
        
)

    [
1] => Array
        (
            [
id] => 44
            
[code] => 375641
            
[pic] => imag0298
            
[category] => Category 2
        
)
    [
2] => Array
        (
            [
id] => 44
            
[code] => 375641
            
[pic] => imag0298
            
[category] => Category 3
        
)
[
3] => Array
        (
            [
id] => 45
            
[code] => 375642
            
[pic] => imag0299
            
[category] => Category 1
        
)
[
4] => Array
        (
            [
id] => 46
            
[code] => 375643
            
[pic] => imag0300
            
[category] => Category 1
        

What i need is

PHP Code:
[0] => Array
        (
            [
id] => 44
            
[code] => 375641
            
[pic] => imag0298
            
[categories] => Array
                                    [
0] = > Category 1
                                    
[1] = > Category 2
                                    
[2] = > Category 3
        
)
[
1] => Array
        (
            [
id] => 45
            
............
            [
categories] => Array
                                    .....
        )
[
2] => Array
        (
            [
id] => 46
            
..........
            [
categories] => Array
                                    .....
        )
[
3] => Array
        (
            [
id] => 47
            
..........
            [
categories] => Array
                                    .....
        )
[
4] => Array
        (
            [
id] => 48
            
..........
            [
categories] => Array
                                    .....
        ) 
Also , is there a way that i can get result as multidimensial array from MYSQL?

I hope i could explain the problem.

Thank you