MySQL EXISTS返回1或0 [英] MySQL EXISTS return 1 or 0

查看:635
本文介绍了MySQL EXISTS返回1或0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为选择查询返回1或0为真和假?我已经尝试过fetch_assoc,数组等的每种组合.它通常返回null,这没有任何意义.

How can I return the 1 or 0 as true and false for my select query? I've tried every combination of fetch_assoc, arrays, etc. It usually returns as null, which doesn't make sense.

$querydetails = "select exists (select * from customer_det where id = $uid)";
$resultdetails = mysql_query($querydetails) or die(mysql_error());
while ($row = mysql_fetch_assoc($resultdetails)) {
    $resultdetails1 = $row[0];
}

这是我查询的最新版本.我猜它不是数组,但是我不确定如果没有要命名的行怎么拉值?

That's the latest version of my query. I guess it's not an array, but I'm not sure how to pull the value if there's no row to be named?

这是我以前的帖子的发帖问题: MySQL Update WHERE

This is a post question to my previous thread: MySQL Update WHERE

推荐答案

SELECT IF(EXISTS(...),1,0) AS result

这篇关于MySQL EXISTS返回1或0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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