在IF语句中的MYSQL SELECT [英] MYSQL SELECT WITHIN IF Statement

查看:483
本文介绍了在IF语句中的MYSQL SELECT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常简单的问题,但我在2小时内没有找到答案。

This is such a simple question but I haven't found an answer anywhere for 2 hours.

如何使用MYSQL IF语句。无论我放入什么都行不通。在SQL Server中,这是一个5秒的工作。

How do you use the MYSQL IF statment. No matter what I put in it doesn't work. In SQL Server this is a 5 second job.

是否需要在一个程序中?

Does it need to be within a procedure?

可以你在IF语句中使用SELECT吗?

Can you use a SELECT within an IF statement?

这里对IF函数不感兴趣。

Not really interested in the IF function here.

谢谢你任何帮助。

推荐答案

如何使用 IF 声明选择

How to use IF statement in select

select if(status>0, 'active', 'inactive') as status from users

是的,你可以在<$ c中使用选择 $ c> IF

Yes, you can use select within IF

示例:

select if((select count(*) from versions) > (select count(*) from groups), true, false) as value

这篇关于在IF语句中的MYSQL SELECT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆