views:

29

answers:

1

Can somebody help get the following pseudocode in mysql? The resulting selects in the IF statement all return the same columns (4) and multiple rows (unknown) so that's not really the problem i'm facing.. How can I get the following structure in Mysql?

//parameters
@p1;
@p2;

@v1;
@v2;

//vars
@t1= 15000;
@t2 = 15000;

//calculated vars
@overlap1 = (@p1 + @v1) > @t1; //boolean
@overlap2 = (@p2 + @v2) > @t2; //boolean
@overlap = @overlap1 OR @overlap2; //boolean


If NOT @overlap Then //no overlap
    CUSTOM SELECT QUERIES (UNION etc..)
ElseIf @overlap1 AND @overlap2 //both overlaps true
    CUSTOM SELECT QUERIES (UNION etc..)
ElseIf @overlap1 //only @overlap1
    CUSTOM SELECT QUERIES (UNION etc..)
Else //only @overlap2
    CUSTOM SELECT QUERIES (UNION etc..)
End If
A: 

I currently generate the right if/then/else part of the mysql query in php. If someone can answer the question properly, please do!

Ropstah