Mysql 的伪代码结构?

发布于 2024-08-19 07:32:05 字数 668 浏览 7 评论 0原文

有人可以帮助在 mysql 中获取以下伪代码吗? IF 语句中的结果选择全部返回相同的列(4)和多行(未知),因此这并不是我面临的真正问题。如何在 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时间海 2024-08-26 07:32:05

我目前在 php.ini 中生成 mysql 查询的正确 if/then/else 部分。如果有人能正确回答这个问题,请回答!

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文