amalosoul Posted November 8, 2006 Share Posted November 8, 2006 I get this error #1064 when I try to run this script can anyone tell me why?table products contains among other things products_statustable products_description contains products_nametable admin_action_log contains products_id,id$query_raport = "SELECT pd.products_name , p.products_status, aal.products_id, count(distinct(aal.id)) count_op, date_format FROM admin_action_log aal left join products p, products_description pd on aal.products_id where aal.id>0 $more_user $more_data $more_op GROUP BY aal.products_id order by 'data' DESC";Thank you in anticipation!(P.S.: I have never used join before so if you need more information please do tell) Quote Link to comment Share on other sites More sharing options...
btherl Posted November 8, 2006 Share Posted November 8, 2006 A problem might be that you are grouping by aal.products_id, then counting distinct aal.idAlso, you will need to aggregate all columns that do not appear in the group by, even ones from other tables. When you join tables, they all become one big table.If you want to aggregate and THEN join, you need to use a subquery.Regarding the error, try using mysql_error() to get a more helpful error message. If possible, use an interactive terminal interface to mysql (or phpmyadmin) to try out your query until you can get it right. It's much easier than doing it via php. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 8, 2006 Share Posted November 8, 2006 Why is data in single quotes? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.