MySQL 数据库错误:操作数应包含 1 列
这是声明。目的并不重要,只是我需要能够判断发布规则属于什么类型的对象。谢谢!
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误表明您应该返回单列而不是两列
解决方法之一是使用
concat_ws
类似The error indicate you should return single column instead of two
One way to fix is to use
concat_ws
like