Moodle database is different from the database module. Moodle database contains all Moodle tables and the database module uses just 4 or 5 of them. Your question should be posted to another forum.
Database
SQL querry
This discussion has been locked so you can no longer reply to it.