fist run the MySQL Query string inside the mysql server if you have it
then put that code in a index.php file on the top.
It will create a memory table for scalability.
The memory will not always be there for example if you reboot it will be gone.
So to save the memory simply create a cron script to pull the data and insert into another table with the same schema but non memory type.