Commands in mysql4 break in mysql5

Both of the below query statements work exactly the same on mysql4 but the top one will break badly on mysql5 – why? notice the "(" and ")" preceding the join command and following the from command

OLD

$sql="select p.title,p.content,p.date_posted,p.category,p.url,p.submitted_user_id,p.ID,pc.cat_title,u.username,pc.ID as cat_id,count(distinct pv.ID) as vote_count, count(distinct pcom.ID) as comment_count from posts p, post_cats pc, users u left join post_votes pv on pv.post_id=p.ID left join post_comments pcom on pcom.post_id=p.ID where pc.ID=p.category and u.ID=p.submitted_user_id ";

NEW

$sql="select p.title,p.content,p.date_posted,p.category,p.url,p.submitted_user_id,p.ID,p.ip_origin,pc.cat_title,u.username,pc.ID as cat_id,count(distinct pv.ID) as vote_count, count(distinct pcom.ID) as comment_count from (posts p, post_cats pc, users u) left join post_votes pv on pv.post_id=p.ID left join post_comments pcom on pcom.post_id=p.ID where pc.ID=p.category and u.ID=p.submitted_user_id ";

Leave a Reply

Your email address will not be published. Required fields are marked *