本文介紹了Zend_Db_Table 子查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一些 SQL 想與 ZendFW 一起使用,但我無法讓它工作,這讓我發瘋.我通過這個查詢得到了正確的結果:
I have a some SQL that I want to use with ZendFW, but I can't get it working and it's driving me crazy. I get the correct result with this query:
SELECT DISTINCT e.festival_id FROM entries AS e, mail_log as m
WHERE e.status = 1
AND e.festival_id
NOT IN (SELECT m.entry_id FROM entries AS e, mail_log as m WHERE m.entry_id = e.festival_id)
幫助將不勝感激.干杯:)
Help would be appreciated. Cheers :)
推薦答案
Goran 的答案是最好的答案.但是如果你想要一個 zend_db_table 樣式的查詢,這將是一個替代:
Goran's answer is the best answer. But if you want a zend_db_table style query, this would be an alternative:
$sql = $table->select()
->setIntegrityCheck(false)
->from('entries', new Zend_Db_Expr('DISTINCT festival'))
->where('status = ?', 1)
->where('festival_id NOT IN (?)',new Zend_Db_Expr("SELECT m.entry_id FROM entries AS e, mail_log as m WHERE m.entry_id = e.festival_id"));
這篇關于Zend_Db_Table 子查詢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!