Jump to content

Optimizing a Query (Ive tried and failed)


rhodesy22

Recommended Posts

I have the following query

[code]SELECT showTable.showID,showTable.name,
timeTable.season,timeTable.episodeID,timeTable.episodeTitle,timeTable.episode,UNIX_TIMESTAMP(timeTable.episodeDate) as date
FROM shows showTable LEFT JOIN tvtimes timeTable
ON showTable.showID=timeTable.showID
WHERE ( showTable.showID='1') AND timeTable.episodeDate<NOW() ORDER BY showTable.name,timeTable.episodeDate DESC[/code]


[code]WHERE ( showTable.showID='1') [/code] would normally be lots of showID's with OR's inbetween


In the timeTable is about 8000 records of all episodes and when they were aired
THe showTable has a list of Shows

The above query does what I want it to do (which is to return all previously Aired episodes) however it's very slow - instead of returning ALL previously Aired episodes I only want it to return the last 1 or last 3 or last 6 or 12 and so on...

I have tried splitting it into two seperate queries but still no luck

Hope you can help.

Thanks in advance!
Link to comment
https://forums.phpfreaks.com/topic/35115-optimizing-a-query-ive-tried-and-failed/
Share on other sites

[quote author=rhodesy22 link=topic=123392.msg509932#msg509932 date=1169408476]
That won't work because im wanting only 3 or 6 or 12 rows from all the shows in the WHERE ( showTable.showID='1' OR showTable.showID='2' etc etc
[/quote]
What?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.