Try it without the brackets around the first join:
SELECT
asset_id
, asset_date
, asset_num
, asset_serialNum
, asset_name
, asset_description
, asset_type
, asset_department
, asset_owner
FROM asset
INNER JOIN monitoring
ON asset.asset_id = monitoring.asset_id
INNER JOIN protocols
ON monitoring.monitor_id = protocols.monitor_id
WHERE monitor_type = 'callibration'
And please be more specific when it “does not work”. Is there an error message, if so what is it? Does it give a result, but not the one you want? If so, give us the result and explain why it isn’t what you want.
Sorry for my lack of info and thanks for your replies.
I was getting no results.
I have now added “asset.” to each of the fields I wish to select and I am now getting a result. The result is the same asset repeated 8 times. The asset listed is the correct asset. I have checked and the monitoring type has 8 protocols. The result seems to be showing the asset the same amount of times as protocols that are setup.
Removing the brackets does not make a difference to the result.
I also see that spelling of calibration is incorrect but it is the spelling I have in the database at the moment. I need to edit my insert query when setting up monitoring with the correct spelling.
Also when I remove the protocols join I get a correct result. (just shows 2 assets with calibration monitoring setup).
Here is my updated code.
"SELECT asset.asset_id, asset.asset_date, asset.asset_num, asset.asset_serialNum, asset.asset_name, asset.asset_description, asset.asset_type, asset.asset_department, asset.asset_owner
FROM
(asset INNER JOIN monitoring
ON asset.asset_id = monitoring.asset_id)
INNER JOIN protocols
ON monitoring.monitor_id = protocols.monitor_id
WHERE monitor_type='callibration'"
SELECT asset.asset_id
, asset.asset_date
, asset.asset_num
, asset.asset_serialNum
, asset.asset_name
, asset.asset_description
, asset.asset_type
, asset.asset_department
, asset.asset_owner
FROM monitoring
INNER
JOIN asset
ON asset.asset_id = monitoring.asset_id)
WHERE monitor_type = 'callibration'
AND EXISTS
( SELECT 'booyah'
FROM protocols
WNERE monitor_id = monitoring.monitor_id )
you can see the effect this has in the query…asset.asset_this, and asset.asset_that… illustrating once again that it is not a good idea to embed the table name into the column name, because of the “noise” this adds to the query