Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
begin
DECLARE `datatable` VARCHAR(20) DEFAULT '`data`';
DECLARE `xtab_query` VARCHAR(4096) DEFAULT '';
 
if(DATE(`dfrom`) > DATE_SUB(NOW(), interval 8 DAY)) then
    SET datatable := "`data_week`"; #last week
else
    if(DATEDIFF(`dto`,`dfrom`)>60) then
        SET datatable := "`data_ms`";#months
    else
        if(DATEDIFF(`dto`,`dfrom`)>14) then
            SET datatable := "`data_ws`"; #weeks
        end if;
    end if;
end if;
 
SET xtab_query := CONCAT("select * FROM ",`datatable`," d ........and 1 screen of query...");
 
PREPARE `xtab_query` FROM @xtab_query;
EXECUTE `xtab_query`;
 
end




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2012