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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.