Hi Marina and William,
A database activity is spread out in four tables.
mdl_data - contains the info about the activity
mdl_data_content - contains the actual data, which fieldid it belongs to, and which record it is part of
mdl_data_fields - contains the field type, name, description, etc.
The table you are interested in is:
mdl_data_records - contains the user id, dataid, timecreated, timemodified, approved, AND groupid
It's that last item, groupid that you need to change. Changing the students group has no affect on that item, but if you know the groupid you have moved the student to, you can change prior entries to the new groupid using something like phpMyAdmin, and then you will see them listed in the group you want them in.