How do I fetch radom values from selected rows in MySQL php

Hello and thanks for checking this out… My aider!

I’m trying to get some values from
a selected row in MySQL table

The table looks like this;

class.   subject.   score.    
----------------------------
A.            maths.      45
----------------------------
B.             phys.          50
----------------------------
B.             phys.          70
----------------------------
A.            maths.      65
----------------------------
B.             phys.          50
----------------------------
A.            maths.      55
----------------------------
B.             phys.          50
----------------------------
A.            maths.      65
----------------------------
B.             phys.          55
----------------------------
A.            maths.      95
----------------------------
B.             phys.          40


Now I want to fetch 3 random score from Maths as subject

Also fetch 3 random score from Phys as subject

How do I fetch these values using PHP and MySQL ?

Thanks :+1:

It looks like you can select random rows using the RAND() function.

MySQL RAND() Function

Scroll all the way to the bottom of the page to see the example for selecting random rows.

Yes I can use the Rand function but how do I combine the query to get random values from both class in the table?