This query returns zero records which leads me to believe I screwed something up?!
SELECT ac.id, ac.body, acr.reviewer_id, acr.rating
FROM article_comment AS ac
INNER JOIN article_comment_review AS acr
ON ac.article_id = acr.article_id
AND ac.member_id = acr.commenter_id
AND ac.created_on = acr.created_on
Looks like this may be more complicated than I want…
Here is what I want to do…
My website has Articles.
Beneath a given Article, Members can post Comments.
And for each Comment, other Members can rate a given Comment on a mini-Form below the Comment.
I have all of this working, but now I want to hide the Comment-Survey Form on Comments for which the logged-in Member has already voted. (Just a visual queue as to which Comments they have or have not reviewed.)
In my “ARTICLE_COMMENT_REVIEW” table, I have a “created_on” field which when populated means a given Comment was rated.
So, if I could add the “ARTICLE_COMMENT_REVIEW” table my current query which populates the Comments section beneath an Article, then that extra piece of information should give my PHP what it needs to show/hide the Comment Form.
Follow me so far?
So I need to join “ARTICLE_COMMENT_REVIEW” to this abridged query…
SELECT m.id AS member_id, m.username, an so on...
ac.id AS comment_id, ac.created_on, ac.comment_no, ac.body
FROM member AS m
INNER JOIN article_comment AS ac
ON m.id = ac.member_id
The problem is that the simplified test query in my OP wasn’t returning any records, and the more that I think about it, I am not sure how to do an Inner Join where the Parent Table has a Composite Key and the Child Table also has a Composite Key?!
it wasn’t a question, it was a statement, and it was intended to get you to look at your posting with fresh eyes, and realize that you hadn’t explained enough about the join
it turns out that the “something simple” was a column that you hadn’t even mentioned
What he’s saying is, regardless of whether it was a typo, oversight, or divine intervention, he had to make guesses rather than educated answers due to the question not providing correct or complete information