DB ERROR

=============================================================================
Mysql_Query : select if(pm.pm_keysub != '', d.uid, pm.uid) as goods_uid from pummok as pm left join pummok d on pm.pm_keysub = d.pm_key inner join morning_search_temp_table st on pm.uid = st.search_pmuid and st.search_sess = '' and st.search_depth = WHERE pm.approval_date > '0' AND pm.pm_delete = 'N' AND pm.goods_grant <= 0 AND pm.pm_category > 0 AND ((pm.goods_name like '%3m%') OR (pm.pm_bookcode like '%3m%') OR (pm.pm_keyword like '%3m%') OR (pm.pm_pumcode like '%3m%') OR (pm.pm_barcode like '%3m%')) and ((pm.pm_keysub != '' and d.pm_delete = 'N' and d.approval_date > '0') or pm.pm_keysub = '' or pm.pm_keysub is null) group by goods_uid
Mysql_Error : 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 'WHERE pm.approval_date > '0' AND pm.pm_delete = 'N' AND pm.good
Mysql Error Num : 1064

=============================================================================