Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Show machines not active in a many-to-many relationship


This topic is 4422 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi,

I have a portal that needs to display machines not active on any maintenance plan in a many-to-many relationship. The tables are (I did not include all fields, as they are not needed):

tblMachines:

MachineID

Serialnumber

ProductID

....

tblMaintenanceContract:

MaintenanceContractID

Active

EndDate

....

tblMachinesMaintenanceContract:

Identifier

MachineID

MaintenanceContractID

Active

....

tblMaintenanceContract can hold many machines from tblMachines. A machine can only be active on 1 maintenance contract on any given time. A maintenance contract that are not active can not hold any active machines.

In the portal I need to show the machine list of machines that are not active on any maintenance contracts.

To the purpose I created the following SQLstring:

SELECT MachineID FROM tblMachines

LEFT JOIN tblMachinesMaintenanceContract ON tblMachines.MachineID=tblMachinesMaintenanceContract.MachineID

WHERE Active='No' AND tblMachines.MachineID NOT IN (SELECT MachineID FROM tblMachines LEFT JOIN tblMachinesMaintenanceContract ON tblMachines.MachineID=tblMachinesMaintenanceContract.MachineID WHERE Active='Yes')

I know for a fact that above SQLstring will display the correct results (testet with SQLBuilder).

I am then trying to use the SQLstring in the filter of portal records but the result is ... nothing.... How can I get the portal to show the results?

Thanks!

This topic is 4422 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.