Error in my query ifnull. why?

Asked

Viewed 53 times

-1

Query that this marked red does not work and blue works!

SELECT * FROM posts LEFT JOIN (SELECT COUNT(id_rela_post), ifnull(qt_vezes, 0), para FROM rela_post GROUP BY para) post_detalhe on posts.id_post = post_detalhe.para

inserir a descrição da imagem aqui

  • Any error appears on the screen?

  • #1064 - You have a syntax error in your SQL next to '(qt_times, 0), for FROM rela_post GROUP BY to) post_detail on posts.id_post ' on line 1

  • 6

    Missing a comma after the COUNT(id_rela_post)

  • n missing comma, I just put and gave Error

  • 3

    Place code as text, not as image.

  • After putting the comma, did you make the same mistake or was it a new mistake? You can place the querys instead of photos/images. We’re a community of programmers, so it’s easier to copy and test than to go to the trouble of having to look at images and type everything back in. If you can help those who help you everything will flow better.

  • I’ve pasted the post, but I don’t understand what difference it makes to have the query if you don’t have the database!

  • The field qt_vezes needs to be in the group by.... o ifnull is not an aggregation function.

  • qt_times it and COUNT AS(id_rela_post) I want it to return 0 instead of null

  • @AKU is required to have in text, as the chance to rewrite its code with a new error (in this case ours) is great. By putting your code in text we can copy it how he is. Consider including all your attempts and error codes for each of them within the question to try to reverse the negative votes and make it easier to fix the problem.

Show 5 more comments

1 answer

2

The correct thing would be to put the IFNULL(COUNT(id_rela_post), 0), instead of putting it in the search alias.

  • did it gave error! still obg by help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.