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
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.