0

我想加入 4 个具有group by, order by&的表limitSQL syntax error当我将 LIMIT 用于分页时,我得到了一个。

SELECT   ads.ad_id            ,
         ads.ad_uid           ,
         ads.ad_title         ,
         ads.ad_content       ,
         ads.ad_name          ,
         ads.ad_price         ,
         ads.ad_maincat       ,
         ads.ad_subcat        ,
         ads.ad_condition     ,
         ads.ad_quantity      ,
         ads.ad_att           ,
         ads.ad_view          ,
         ads.ad_aff           ,
         ads.ad_status        ,
         ads_images.img_id    ,
         ads_images.img_aid   ,
         ads_images.img_uid   ,
         ads_images.img_big   ,
         ads_images.img_bigx  ,
         ads_images.img_bigy  ,
         ads_images.img_thumb ,
         ads_images.img_sort  ,
         users.user_username  ,
         users.user_fullname  ,
         users.user_gravatar  ,
         users.user_id        ,
         categories.cat_id    ,
         categories.cat_parent,
         categories.cat_name  ,
         categories.cat_slug
FROM     ads
         INNER JOIN ads_images
         ON       ads.ad_id = ads_images.img_aid
         INNER JOIN users
         ON       ads.ad_uid = users.user_id
         INNER JOIN categories
         ON       ads.ad_maincat = categories.cat_parent
         AND      ads.ad_subcat  = categories.cat_id
WHERE    ads.ad_status           = 1
AND
GROUP BY ads.ad_id 
ORDER BY
ads.ad_id DESC
LIMIT {$startpoint},{$limit}

我可以知道使用的正确语句是什么LIMITGROUP BY

4

1 回答 1

1

删除AND之前的错误GROUP

于 2012-04-17T19:17:41.040 回答