0

我正在执行这两个查询。

1.

select widget_uid,param_value as campaign_name
from widget_config_value
where widget_uid in (select widget_uid
                     from widget_config_value
                     where param_name="active"
                           and param_value="1"
                           and widget_uid in (select widget_uid
                                              from partner_widget
                                              where partner_uid=4)
                    )
       and param_name="widgetCampaignName";

2.

select widget_uid,param_value as campaign_type
from widget_config_value
where widget_uid in (select widget_uid
                     from widget_config_value
                     where param_name="active"
                           and param_value="1"
                           and widget_uid in (select widget_uid
                                              from partner_widget
                                              where partner_uid=4)
                    )
      and  param_name="widgetType";

我怎样才能在 widget_uid 上加入这个?所以,我可以获得常见widget_uid的结果??

或者有什么办法可以改善上述查询?

4

2 回答 2

1

您可以通过以下方式尝试 -

select widget_uid, campaign_name, campaign_type from
(select widget_uid,param_value as campaign_name from widget_config_value 
where widget_uid in 
(select widget_uid from widget_config_value 
where param_name="active" 
and param_value="1" 
and widget_uid in (select widget_uid from partner_widget where partner_uid=4)) 
and param_name="widgetCampaignName") tbl1,
(select widget_uid,param_value as campaign_type 
from widget_config_value 
where widget_uid in 
(select widget_uid 
from widget_config_value 
where param_name="active" 
and param_value="1" 
and widget_uid in (select widget_uid from partner_widget where partner_uid=4)) 
and param_name="widgetType") tbl2
where tbl1.widget_uid = tbl2.widget_uid;
于 2012-05-15T07:18:08.600 回答
0

我认为查询不起作用,因为不可能

param_name="active" and param_name="widgetCampaignName" 

在同一时间。也查询没有。2

查看您的查询

select 
    widget_uid,param_value as campaign_name 
from widget_config_value
where 
    widget_uid in (
        select widget_uid 
        from 
            widget_config_value 
        where 
            param_name="active" and 
            param_value="1" and 
            widget_uid in (
                select widget_uid 
                from partner_widget 
                where partner_uid=4)
            ) and
     param_name="widgetCampaignName";

在这部分

select widget_uid 
        from 
            widget_config_value 
        where 
            param_name="active" and 
            param_value="1" and 
            widget_uid in (
                select widget_uid 
                from partner_widget 
                where partner_uid=4)
            )

给你widget_config_value不可能拥有的数据param_name not equal to "active"。所以param_name="widgetCampaignName"没用。

于 2012-05-15T06:56:19.303 回答