我怎麼能寫使用CakePHP找到()提前轉換這個SQL把CakePHP的發現()
SELECT a.user_id FROM answers a
INNER JOIN answers a1 ON a1.question_id=1 AND a1.answer_value='Pooch'
INNER JOIN answers a2 ON a2.question_id=2 AND a2.answer_value='Peach'
GROUP BY a.user_id
感謝
我怎麼能寫使用CakePHP找到()提前轉換這個SQL把CakePHP的發現()
SELECT a.user_id FROM answers a
INNER JOIN answers a1 ON a1.question_id=1 AND a1.answer_value='Pooch'
INNER JOIN answers a2 ON a2.question_id=2 AND a2.answer_value='Peach'
GROUP BY a.user_id
感謝
您可以使用ad hoc joins或建立一個自我指涉米奧德爾協會。前者可能是最簡單的選擇,因爲它只是構建你已經瞭解和理解的SQL。 :-)
您可以通過dogmatic69在這裏使用轉換器:http://cakephptutor.wordpress.com/2013/02/25/convert-sql-query-to-cakefind/
試試這個:http://stackoverflow.com/questions/806650/in-cakephp-how-to-retrieve-joined-result-from-多表 – minaz
我需要以不同的標準加入同一張表 – chchrist