我有一個使用php活動記錄的codeigniter項目。有3個表格(用戶,打孔和作業)當我運行此查詢時php activerecord ORDER BY導致查詢失敗
$records = Punches::find_by_sql("Select * from jobs,users,punches where jobs.job_id = $job_id AND punches.job_id = $job_id AND punches.id= users.id AND NOT ISNULL(end_time) ORDER BY last_name,id ");
查詢失敗。如果我把這個命令拿出來,它就可以工作了。請注意我已經使用了我能想到的ORDER BY的每個變體。
忘記DESC或ASC ..? – 2013-03-04 04:35:30
這個查詢在phpmyadmin中運行?什麼是錯誤? – 2013-03-04 04:35:34
只是一個猜測,但做多個表共享列名'ID'或姓氏? – 2013-03-04 04:36:10