Fetch Data from ID

Fetch Data from ID

Hi

I'm trying to populate a table based on the ID number of a record. 

I have a table (Main) with People & Courses having lookup values as their records

People      Courses
3081044      3001505
3150808      3205808
3081044      3045088

I want to fetch records in this table where People = the ID number of the People table when I edit the People table.

So; user edits People table (maybe adds a new course that the person needs to do). When they click 'Update', this code kicks in...

training_records  =  Main  [People == ID];
// where People in the Main table (3081044) equals the ID for this current record
alert input.ID;
alert training_records.People;
alert training_records.count();

The record has an ID number (because we are editing an existing record) but the alert returns null, therefore the RecordCount is 0. I can't figure out why it's doing this. Both the ID and the People record should read 3081044 as that is the ID of the person.

The idea is that I check each element in a multiselect to see whether or not there is a training record in the 'Main' table, then flip it around and remove any training sessions that are no longer required. Basically comparing a multi select against a database. 

Can anyone point me in the right direction please?

Thanks