I hope this is the right place to ask this. I'm using perl and mysql and I'm having trouble figuring out a query. I have three tables - Activities, Sponsors and Links. In the activities table I want to select all the rows for a given date range. That part is simple and done. But, in this table are three fields in particular for each record where I need to get info from other tables, sponsor1id, sponsor2id and linkid. The first two of these are id's that relate to separate records in the Sponsors table and as part of the query I want to get the SponsorName from the Sponsor table for those two columns. For the linkid field, I need to pull the url from the Links table based upon that records linkid. I'm totally baffled. Can this be done in a single query.
I know normally if I wanted to pull data from two tables, I would do something like
SELECT fields from Activities,Links where Activities.linkid = Links.linkid AND Activities.date = range
But what has me baffled is that I want to pull two records from the Sponsors and one from the Links table for each result returned.
Also, will doing it this way bog down the server / slow down the query dramatically... I figured because there are a lot of records, probably half a million when I finish the first cut, I didn't want to repeat so much data over and over and over again so I created "lookup tables".
If anyone can help I'd be most appreciative.
I know normally if I wanted to pull data from two tables, I would do something like
SELECT fields from Activities,Links where Activities.linkid = Links.linkid AND Activities.date = range
But what has me baffled is that I want to pull two records from the Sponsors and one from the Links table for each result returned.
Also, will doing it this way bog down the server / slow down the query dramatically... I figured because there are a lot of records, probably half a million when I finish the first cut, I didn't want to repeat so much data over and over and over again so I created "lookup tables".
If anyone can help I'd be most appreciative.