0
如何將這兩個查詢放入單個查詢中?某種聯接語句?
select count(id) as cnt from {$site_id}.proofingv2_packages where active='1'
select count(id) as cnt from {$site_id}.proofingv2_package_options where active='1' and parent={$row["id"]} order by sort
$row['id']
是來自第一個查詢的id字段。我試圖確定是否有任何有效的軟件包。有效的軟件包必須處於活動狀態,並且至少有一個活動選項。爲此運行2個查詢似乎不正確。
任何人都可以幫忙嗎?
謝謝。更新爲:'select count(id)as cnt from {$ site_id} .proofingv2_packages pp INNER JOIN {$ site_id} .proofingv2_package_options pt ON pp.id = pt.parent WHERE pp.active = 1 AND pt.active = 1' – John 2011-02-23 10:54:05