Moodle will know what to do ;)
If you need to do it as part of your script, you will want to do some SQL JOINs.
Here's some examples. The basic JOIN yo uwant looks like:
SELECT
s.*,u.idnumber,c.idnumber
FROM mdl_user_students s
JOIN mdl_user u ON s.userid=u.id
JOIN mdl_course c ON c.id=s.course
LIMIT 10;
(I put the limit 10 just in case, you don't need it).
If you want to narrow it down to a particular user you add a where clause:
SELECT
s.*,u.idnumber,c.idnumber
FROM mdl_user_students s
JOIN mdl_user u ON s.userid=u.id
JOIN mdl_course c ON c.id=s.course
WHERE u.idnumber = '#######'
(Replace ##### with the student id)
If you want to narrow down on a per-course basis look for the course id (c.idnumber) rather than for the user id (u.idnumber):
SELECT
s.*,u.idnumber,c.idnumber
FROM mdl_user_students s
JOIN mdl_user u ON s.userid=u.id
JOIN mdl_course c ON c.id=s.course
WHERE c.idnumber = '#######'
If this sounds too comples, check out the many SQL primers on Google.
Enrolment
Change id data type in mdl_course
This discussion has been locked so you can no longer reply to it.