MySQL error problem
I get the following error below and was wondering how can I correct this problem?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to u开发者_高级运维se near 'IF(articles_comments.parent_comment_id = articles_comments.comment_id AND users.' at line 4
Here is my MySQL code.
SELECT *
FROM users
INNER JOIN articles_comments ON users.user_id = articles_comments.user_id
IF(articles_comments.parent_comment_id = articles_comments.comment_id AND users.active IS NULL AND users.deletion = 0) AS no
AND users.active IS NULL
AND users.deletion = 0
SELECT *
FROM users
INNER JOIN articles_comments ON users.user_id = articles_comments.user_id
WHERE (articles_comments.parent_comment_id = articles_comments.comment_id AND users.active IS NULL AND users.deletion = 0)
AND users.active IS NULL
AND users.deletion = 0
That query doesn't make sense at the moment.... I think you have got the WHERE CLAUSE mixed up with the IF clause.
Your question is a little vague too, it is hard to understand what you are trying to do.
Your Select * From, JOIN part is ok.
You need to use the WHERE clause instead tho.
i.e.
SELECT * FROM USERS
INNER JOIN articles_comments ON users.user_id = articles_comments.user_id
AND articles_comments.parent_comment_id = articles_comments.comment_id
WHERE users.active IS NULL
AND users.deletion = 0
You don't seem to be selecting anything fomr the articles_comments table though? A more thorough explantion of the problem will help.
It's difficult to find out what you are trying to do here, but in order to filter (put a condition) your query, you need a where clause
.
Also, your IF
statement is misplaced.
Something like this:
SELECT *
FROM users INNER JOIN articles_comments ON users.user_id = articles_comments.user_id
WHERE users.active IS NULL
AND users.deletion = 0
精彩评论