0

私はこれらの2つのクエリを実行しています。

1.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.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 に答える