0

I am using Views to display some comment for specify node.

The SQL query on Views pane:

SELECT comment.uid AS comment_uid, comment.cid AS cid, comment.created AS comment_created, 'comment' AS field_data_comment_body_comment_entity_type
FROM 
{comment} comment
INNER JOIN {node} node_comment ON comment.nid = node_comment.nid
WHERE (( (node_comment.nid = '1330' ) )AND(( (comment.status <> '0') AND (node_comment.status = '1') )))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

I try to copy above sql to phpmyadmin:

SELECT comment.uid AS comment_uid, comment.cid AS cid, comment.created AS comment_created, 'comment' AS field_data_comment_body_comment_entity_type
FROM 
comment
INNER JOIN node_comment ON comment.nid = node_comment.nid
WHERE (( (node_comment.nid = '1330' ) )AND(( (comment.status <> '0') AND (node_comment.status = '1') )))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

But phpmyadmin throw an error to me:

Error Code: 1146. Table 'daxuebao.node_comment' doesn't exist

I try to search drupal node_comment table at google, But I get nothing.

1
  • Your query is wrong.. Just remove braces {} from Views Query and execute..
    – Anil Sagar
    Mar 27, 2014 at 7:02

1 Answer 1

2

There is no table named node_comment. You must do the inner join to the node table, in the same way as the Views query.

SELECT comment.uid AS comment_uid, comment.cid AS cid, comment.created AS comment_created, 'comment' AS field_data_comment_body_comment_entity_type
FROM 
comment
INNER JOIN node node_comment ON comment.nid = node_comment.nid
WHERE (( (node_comment.nid = '1330' ) )AND(( (comment.status <> '0') AND (node_comment.status = '1') )))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.