How to view what query was ran when a form is submitted?
Install the devel module https://drupal.org/project/devel, and choose the option display query log. The queries will be shown on the bottom of each page.

In admin/config/development/devel:

Check 'display query log'

Sometimes, I prefer just switching on logging in my.cnf for MySQL, because it shows the complete query as executed. If you do that, do not forget to switch logging off again when you are done. Otherwise, you'll fill up your disk/partition. 

In the [mysqld]section, add:

log=/var/log/mysqld


Restart mysqld.