本文介绍了在亚音速表的别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以指定别名表亚音速2.1?

How can I assign alias to tables with SubSonic 2.1?

我试图重现以下查询:

SELECT *
FROM posts P
RIGHT OUTER JOIN post_meta X ON P.post_id = X.post_id
RIGHT OUTER JOIN post_meta Y ON P.post_id = Y.post_id
WHERE X.meta_key = "category"
    AND X.meta_value = "technology"
    AND Y.meta_key = "keyword"
    AND Y.meta_value = "cloud"

我现在用亚音速2.1升级到2.2不是一个选项(还)。谢谢你。

I'm am using SubSonic 2.1 and upgrading to 2.2 isn't an option (yet). Thanks.

推荐答案

使用一个观点:

CREATE VIEW post_meta2 AS SELECT * FROM post_meta

那么你的查询就会变成:

Then your query becomes:

SELECT *
FROM posts
RIGHT OUTER JOIN post_meta ON posts.post_id = post_meta.post_id
RIGHT OUTER JOIN post_meta2 ON posts.post_id = post_meta2.post_id
WHERE post_meta.meta_key = "category"
    AND post_meta.meta_value = "technology"
    AND post_meta2.meta_key = "keyword"
    AND post_meta2.meta_value = "cloud"

是的,我知道,这是原油。但是,有效的事业。如果你想优雅然后再升级作为已经提出,否则这应该是足够了一个临时的解决方法。

Yes, I know, it's crude. But effective nonetheless. If you want elegance then upgrade as has already been suggested, otherwise this should be sufficient for a temporary workaround.

这篇关于在亚音速表的别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 05:02