Jump to content

Error #1064 ?


amalosoul

Recommended Posts

I get this error #1064 when I try to run this script can anyone tell me why?

table products contains among other things products_status
table products_description contains products_name
table 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)
Link to comment
https://forums.phpfreaks.com/topic/26549-error-1064/
Share on other sites

A problem might be that you are grouping by aal.products_id, then counting distinct aal.id
Also, 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.
Link to comment
https://forums.phpfreaks.com/topic/26549-error-1064/#findComment-121477
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.