gpt4 book ai didi

mysql - 格式化 mysql 查询输出

转载 作者:行者123 更新时间:2023-11-29 08:52:38 24 4
gpt4 key购买 nike

在我的查询中,我想检查具有指定权限的用户是否存在。目前我正在使用以下查询。它将检索具有指定条件的授权用户的行。

select a.ixUserAuthorization from tblechecklistuserroleassignmentxref r
inner join tblechecklistuserrole u on u.ixUserRole=r.ixUserRole and u.sname='Initiator'
inner join tblechecklistuserauthorization a on a.ixUserAuthorization=r.ixUserAuthorization
and a.ixcustomer='1'and a.ixprogram='1'and a.ixworkpackage='1'and a.ixactivity='1' and a.ixUser='626e28e8-e67a-4d11-8d2c-129d0ab79e96';

如果返回任何行,我想将结果显示为 true ,如果上面的查询没有返回行,我想将结果显示为 false。

如何修改以获得 true 或 false 的结果。

最佳答案

SELECT CASE 
WHEN Count(*) >= 1 THEN 'true'
ELSE 'false'
END AS Answer
FROM (SELECT a.ixUserAuthorization
FROM tblechecklistuserroleassignmentxref r
INNER JOIN tblechecklistuserrole u
ON u.ixUserRole = r.ixUserRole
AND u.sname = 'Initiator'
INNER JOIN tblechecklistuserauthorization a
ON a.ixUserAuthorization = r.ixUserAuthorization
AND a.ixcustomer = '1'
AND a.ixprogram = '1'
AND a.ixworkpackage = '1'
AND a.ixactivity = '1'
AND a.ixUser = '626e28e8-e67a-4d11-8d2c-129d0ab79e96') a

关于mysql - 格式化 mysql 查询输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10780665/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com