-
How to nest 2 queries
Hi all,
here's query 1In my first query I have all the main data retrieved from the database, here's how it looks):
SELECT
From_Codes.CITY,
To_Codes.CITY,
zone_Codes.CITY,
zone_Codes.CODE,
ConZones.cities,
To_Codes.CODE,
airlines.Carrier,
airlines.Via,
ConMain.Period,
ConMain.Fare,
ConMain.Type,
ConMain.Class
FROM ((ConZones RIGHT JOIN (CODES AS From_Codes
RIGHT JOIN (ConMain
LEFT JOIN CODES AS To_Codes
ON ConMain.d_To = To_Codes.CODE)
ON From_Codes.CODE = ConMain.d_From)
ON ConZones.Zone = ConMain.d_From)
LEFT JOIN CODES AS zone_Codes
ON ConZones.cities = zone_Codes.CODE)
INNER JOIN airlines ON ConMain.airline = airlines.c_ID
And, because the addition of more tables and outer joins to the first query got very complicated, I had to add an additional query that would look something like this:
select airline, season, date_start, date_end
FROM seasons
WHERE airline = 'query1.carrier'
AND season = 'query1.season'
Now I want to join the two queries, because in the first query where I choose all the records, I want to be able to trim the results, and in case the client submits a travel date, I want to evaluate that date against the seasonal period (in the query 1), and then choose only those records (from the query 2) that their 'period coloumn' match the 'season coloumn' in the 2'nd query.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|