php - MySQL left join count with condition -


I have two tables:

  • cc_videos: ID, challenge_id , uploaded, owner_id

  • fields ID, video_id, vote_date

  • of

    Field "ID" "Cc_videos" corresponds with cc_video_votes

      select join cc_videos cc_video_votes *, COUNT (video_id) cc_video_votes on cc_videos.id left as votes_count the cc_videos =: an area "video_id" "cc_video_votes" In and I have made such a statement .. The number of orders by cc_videos.id orders Video_id GROUP  

    Now it works fine - the most votes were sorted according to the first video with rate lists all the videos I Where "cc_videos" matches challenge_id variable "$ challenge_id" want to keep the condition of the video listed only, but when I put the condition like this it returns 0 results.

      cc_videos *, COUNT (video_id) cc_videos where challenge_id = "$ challenge_id" left cc_videos.id = cc_video_votes.video_id Group votes_count by cc_videos.id ordered by cc_video_votes desc  JOIN as votes_count 

    I am using, where segment is right?

    No, you are not.

      SELECT cc_videos *, COUNT (video_id) cc_videos.id = cc_video_votes.video_id cc_video_votes Join LEFT where cc_videos.challenge_id = "votes_count desc  Group by cc_videos.id ordered by $ challenge_id" as the votes_count the cc_videos 

    WHERE should remain in the syntax section,


    Comments

    Popular posts from this blog

    sqlite3 - UPDATE a table from the SELECT of another one -

    c# - Showing a SelectedItem's Property -

    javascript - Render HTML after each iteration in loop -