Sql queries 10 pieces of data for each category

a table

a_id name 
1    1

2    2

3    3

4    4

5    5

b table

b_id name a_id
1    a    1

2    b    1

3    c    1

4    d    2

5    e    2

how to write the sql statement to query 10 pieces of data for each category

find an array structure similar to the following:

array(
    array(
        "a_id"=>1,
        "a_name"=>1
        "b_list"=>array{
            array(
                "b_id"=>1,
                "b_name"=>a,
                "a_id"=>1,
            ),
            
            array(
                "b_id"=>1,
                "b_name"=>a,
                "a_id"=>1,
            ),
        }
    },
    array(
        "a_id"=>1,
        "a_name"=>1
        "b_list"=>array{
            array(
                "b_id"=>1,
                "b_name"=>a,
                "a_id"=>1,
            ),
            
            array(
                "b_id"=>1,
                "b_name"=>a,
                "a_id"=>1,
            ),
        }
    },
);

I"m not sure if this structure can be checked by mysql. How efficient is it? I want to toss about (A V A)

.
Mar.24,2022

A way of using grouping and trickery
SELECT * FROM b WHERE b.id in (
SELECT GROUP_CONCAT (b.id) FROM an INNER JOIN b on a.id = b.aid GROUP BY a.id HAVING COUNT (*) < 11
)

The idea of

is to get 10 id of the b table of the group, then look it up in the model text, and finally get 10

of each group.

if it is up to date, sort it using


UNION query?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b315ee-2b0f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b315ee-2b0f0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?