3
我正在處理兩個表(urls
和companies
)的簡單JOIN
。我使用這個查詢電話:爲什麼Zend Framework(Zend_Db_table)拒絕這個SQL查詢?
print $this->_db->select()->from(array('u' => 'urls'),
array('id', 'url', 'company_id'))
->join(array('c' => 'companies'),
'u.company_id = c.id');
該出把這個查詢:
SELECT `u`.`id`, `u`.`url`, `u`.`company_id`, `c`.* FROM `urls` AS `u` INNER JOIN `companies` AS `c` ON u.company_id = c.id
現在,我寧願在c.*
不實際出現,但無論哪種方式並不重要。 ZF死於此錯誤:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"
但我可以在MySQL CLI中完美地運行該查詢。任何想法如何修復這個查詢?
檢查是否已在公司保留關鍵字(場)表。 http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html – 2010-06-10 21:35:05