MySQL 数据库错误:操作数应包含 1 列

发布于 2024-10-09 00:35:06 字数 969 浏览 0 评论 0原文

这是声明。目的并不重要,只是我需要能够判断发布规则属于什么类型的对象。谢谢!

select case(select count(mediaitemguid) from mediaitempublicationrules where publicationruleguid = '<snip>')
       when 0 then case(select count(catalogguid) from catalogpublicationrules where publicationruleguid = '<snip>')
           when 0 then case(select count(domainguid) from domaindefaultpublicationrules where publicationruleguid = '<snip>')
              when 0 then null
             else (select 'Domain', domainguid from domaindefaultpublicationrules where publicationruleguid = '<snip>')
             end
           else (select 'Catalog', catalogguid from catalogpublicationrules where publicationruleguid = '<snip>')
           end
       else (select 'MediaItem', mediaitemguid from mediaitempublicationrules where publicationruleguid = '<snip>')
       end;

编辑:更多的澄清...这工作得很好,直到我将这些“域”“目录”“媒体项”条目放入 else 语句的嵌套选择中。这可能相当简单,只是之前没有遇到过这个错误

Here is the statement. The purpose isn't really important, just that I need to be able to tell what type of object the publication rule belongs to. Thanks!

select case(select count(mediaitemguid) from mediaitempublicationrules where publicationruleguid = '<snip>')
       when 0 then case(select count(catalogguid) from catalogpublicationrules where publicationruleguid = '<snip>')
           when 0 then case(select count(domainguid) from domaindefaultpublicationrules where publicationruleguid = '<snip>')
              when 0 then null
             else (select 'Domain', domainguid from domaindefaultpublicationrules where publicationruleguid = '<snip>')
             end
           else (select 'Catalog', catalogguid from catalogpublicationrules where publicationruleguid = '<snip>')
           end
       else (select 'MediaItem', mediaitemguid from mediaitempublicationrules where publicationruleguid = '<snip>')
       end;

EDIT: a little more clarification...this worked just fine until I put those 'Domain' 'Catalog' 'MediaItem' entries into the nested selects on the else statements. It's probably something fairly simple, just haven't run into that error before

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

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

发布评论

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

评论(1

爱的十字路口 2024-10-16 00:35:06

该错误表明您应该返回单列而不是两列

解决方法之一是使用 concat_ws 类似

select concat_ws(':', 'Domain', domainguid') ... <-- ':' is the delimiter

The error indicate you should return single column instead of two

One way to fix is to use concat_ws like

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