Does anyone know how to do a conditional query on 1 table if data exists in another? I created 2 tables, location and speedtest. if you run a query against speedtest it will run the test so I don't want to query against it unless certain conditions are met. IE if (select location = 'somewhere') Then (select * from speedtest). The location and speedtest tables do not share any common attributes, and there will be a lot of other conditions added in the future so I don't want to have to modify the speedtest table to include additional common attributes down the road.
I can make it work using a case statement, but it will only work for 1 attribute in the speedtest table. I need to be able to pull all values. Example:
SELECT location,
CASE location
WHEN 'Building R (Wireless)' THEN
(SELECT download FROM speedtest)
ELSE 'skipped'
END download
FROM location
Will return
hostname | download | location
<host> | 601.34Mbit/s | Building R (Wireless)
But I need all the attributes out of speedtest, which include latency, upload, etc.
Using the case statement I would have to create an additional case for every other attribute which would mean the speedtest would run multiple times.
Any ideas?