models.php
->add_subquery('(SELECT character_name FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter')
->add_subquery('(SELECT character_detail_id FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter_id')
->add_subquery('(SELECT character_icon FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter_icon')
以上是我使用的三个子查询character_name
,character_detail_id
&来自character_icon
表的zid_character_details
,参考zid_guild_feeds
表。
任何人都可以告诉我如何将这三个查询优化为单个或简单的查询。
由于
答案 0 :(得分:0)
查看Kohana Query Builder Joins和Kohana Query Builder Subqueries
当您需要探索各种ORM时,我建议您查看Leap ORM