[mythtv] Joining on a calculated column

Chris Petersen lists at forevermore.net
Tue Jan 11 16:45:29 EST 2005


> You all tell me which is more efficient, temp table or duplicating the
> function.  The function is below.  It goes in the big, ugly, scheduler
> query and needs to returned in the SELECT list and used in JOINs for
> recorded and oldrecorded.

time to learn how to use EXPLAIN...  it's VERY useful in building your 
mysql queries.

-Chris

>     QString progfindid = QString(
> "(CASE record.type "
> "  WHEN %1 "
> "   THEN to_days(date_sub(program.starttime, interval "
> "                date_format(record.findtime, '%H:%i') hour_minute)) "
> "  WHEN %2 "
> "   THEN floor((to_days(date_sub(program.starttime, interval "
> "               date_format(record.findtime, '%H:%i') hour_minute)) - "
> "               to_days(record.findtime))/7) * 7 + to_days(record.findtime) "
> "  ELSE 0 "
> " END) ")
>         .arg(kFindDailyRecord)
>         .arg(kFindWeeklyRecord);
> 
> David
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


More information about the mythtv-dev mailing list