skip to Main Content

Hi i am using PHPMYAdmin MYSQL in godaddy-vps server while using it i am getting an error when executing my SQL Query

I want total count of likes.post_id in likes table based on posts.user_id=2 posts list, by joining two table by likes.post_id=posts.id where likes_status=’true’

SELECT likes.post_id, likes.like_status, P.id, P.user_id, 
  count(*) AS likeCountProfilePosts  FROM likes 
  INNER JOIN posts AS P ON P.id=likes.post_id  
  WHERE P.id IN (SELECT id FROM posts WHERE posts.user_id =2) 
  AND likes.like_status='true' 

Getting error :

#1140 – In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column ‘howtags_social_db.likes.post_id’; this is incompatible with sql_mode=only_full_group_by

If anyone know the solution please tell me

2

Answers


  1. Chosen as BEST ANSWER

    I just updated my SQL query and its working fine for me instead of changing PHPMyAdmin settings

     SELECT comments.post_id,  
      count(*) AS commentCount FROM comments  
      INNER JOIN posts AS P on P.id=comments.post_id  
      GROUP BY comments.post_id  
      ORDER BY comments.post_id DESC
    

  2. Try this,
    1. Open godaddy panel
    2. Open phpmyadmin
    3. Open Variable Setting
    enter image description here

    1. Search MySQL mode
    2. Delete Only Full Group By on MySQL mode variables
      enter image description here
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search