Hello there,
In your database i would assume that each module has a name, for example 'hugo'. When checking for places available this is what i would suggest.
Have a field, hidden or otherwise, with the value of the module being joined, which i will name 'modname'. The same name i will use in the database.
I hope this code makes sence and helps.