Pseudo codestructure to Mysql?
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)开发者_StackOverflow中文版 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
I currently generate the right if/then/else part of the mysql query in php. If someone can answer the question properly, please do!
精彩评论