I am having difficulty with a SQL query in my project.
I have 3 tables.
T1:
- Date
- ID
- Location_ID
T2:
- Location
- Location_ID
T3:
- ID
- Result
From this I need the T1.Date and T3.Result based on Location in T2.
So my I need a query to compare a known location, get the Location_ID. Then Use that Location_ID to get the Date and ID. Use the ID to get the Result from T3. (Value is a variable with the known Location)
This is what I have tried:
"SELECT T1.Date,T3.Result _
FROM T1,T2,T3 _
WHERE T1.Location_ID = (SELECT T2.Location_ID FROM T2 WHERE T2.Location = '" & Value & "') AND T3.ID = (SELECT T1.ID FROM T1 WHERE T1.Location_ID = (SELECT T2.Location_ID FROM T2 WHERE T2.Location = '" & Value & "'))"
I get the error 'Sub query returns more than 1 value...'
What am I doing wrong?